public Value GetValue(RandomShift random) { if (fixedValue != null) { return fixedValue; } // Generate random value. switch (binType) { case BinType.Integer: return Value.Get(random.Next()); case BinType.String: StringBuilder sb = new StringBuilder(binSize); for (int i = 0; i < binSize; i++) { sb.Append((char) random.Next(33,127)); } return Value.Get(sb.ToString()); case BinType.Byte: byte[] bytes = new byte[binSize]; random.NextBytes(bytes); return Value.Get(bytes); default: return null; } }
public BenchmarkThread(Console console, BenchmarkArguments args, BenchmarkShared shared, Example example) { this.console = console; this.args = args; this.shared = shared; this.example = example; random = new RandomShift(); }
public void SetFixedValue() { // Fixed values are used when the extra random call overhead is not wanted // in the benchmark measurement. RandomShift random = new RandomShift(); fixedValue = GetValue(random); }