From 582b0eb54fb9b046dc70323acad70018043a95dc Mon Sep 17 00:00:00 2001 From: David Renshaw Date: Wed, 1 Oct 2014 17:18:19 -0400 Subject: [PATCH] teensy optimizations --- benchmark/src/main/java/org/capnproto/benchmark/CarSales.java | 4 +++- benchmark/src/main/java/org/capnproto/benchmark/Eval.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/benchmark/src/main/java/org/capnproto/benchmark/CarSales.java b/benchmark/src/main/java/org/capnproto/benchmark/CarSales.java index e36d008..9ba72cb 100644 --- a/benchmark/src/main/java/org/capnproto/benchmark/CarSales.java +++ b/benchmark/src/main/java/org/capnproto/benchmark/CarSales.java @@ -49,11 +49,13 @@ public class CarSales new Text.Reader("Volt"), new Text.Reader("Accord"), new Text.Reader("Leaf"), new Text.Reader("Model S")}; + static final Color colors[] = Color.values(); + static final void randomCar(Common.FastRand rng, Car.Builder car) { car.setMake(MAKES[rng.nextLessThan(MAKES.length)]); car.setModel(MODELS[rng.nextLessThan(MODELS.length)]); - car.setColor(Color.values()[rng.nextLessThan(Color.SILVER.ordinal() + 1)]); + car.setColor(colors[rng.nextLessThan(Color.SILVER.ordinal() + 1)]); car.setSeats((byte)(2 + rng.nextLessThan(6))); car.setDoors((byte)(2 + rng.nextLessThan(3))); diff --git a/benchmark/src/main/java/org/capnproto/benchmark/Eval.java b/benchmark/src/main/java/org/capnproto/benchmark/Eval.java index 287cf13..4b41aad 100644 --- a/benchmark/src/main/java/org/capnproto/benchmark/Eval.java +++ b/benchmark/src/main/java/org/capnproto/benchmark/Eval.java @@ -9,8 +9,10 @@ public class Eval extends TestCase { + static final Operation operations[] = Operation.values(); + public static int makeExpression(Common.FastRand rng, Expression.Builder exp, int depth) { - exp.setOp(Operation.values()[rng.nextLessThan(Operation.MODULUS.ordinal() + 1)]); + exp.setOp(operations[rng.nextLessThan(Operation.MODULUS.ordinal() + 1)]); int left = 0; if (rng.nextLessThan(8) < depth) {