teensy optimizations
This commit is contained in:
parent
ad161e1569
commit
582b0eb54f
2 changed files with 6 additions and 2 deletions
|
@ -49,11 +49,13 @@ public class CarSales
|
||||||
new Text.Reader("Volt"), new Text.Reader("Accord"),
|
new Text.Reader("Volt"), new Text.Reader("Accord"),
|
||||||
new Text.Reader("Leaf"), new Text.Reader("Model S")};
|
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) {
|
static final void randomCar(Common.FastRand rng, Car.Builder car) {
|
||||||
car.setMake(MAKES[rng.nextLessThan(MAKES.length)]);
|
car.setMake(MAKES[rng.nextLessThan(MAKES.length)]);
|
||||||
car.setModel(MODELS[rng.nextLessThan(MODELS.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.setSeats((byte)(2 + rng.nextLessThan(6)));
|
||||||
car.setDoors((byte)(2 + rng.nextLessThan(3)));
|
car.setDoors((byte)(2 + rng.nextLessThan(3)));
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,10 @@ public class Eval
|
||||||
extends TestCase<Expression.Factory, Expression.Builder, Expression.Reader,
|
extends TestCase<Expression.Factory, Expression.Builder, Expression.Reader,
|
||||||
EvaluationResult.Factory, EvaluationResult.Builder, EvaluationResult.Reader, Integer> {
|
EvaluationResult.Factory, EvaluationResult.Builder, EvaluationResult.Reader, Integer> {
|
||||||
|
|
||||||
|
static final Operation operations[] = Operation.values();
|
||||||
|
|
||||||
public static int makeExpression(Common.FastRand rng, Expression.Builder exp, int depth) {
|
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;
|
int left = 0;
|
||||||
if (rng.nextLessThan(8) < depth) {
|
if (rng.nextLessThan(8) < depth) {
|
||||||
|
|
Loading…
Reference in a new issue