Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 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();
 }