Example #1
0
            /// <summary>
            /// Constructor.
            /// </summary>
            /// <param name="benchmark">Benchmark.</param>
            /// <param name="descList">Descriptor list.</param>
            public BenchmarkTask(BenchmarkBase benchmark,
                                 ICollection <BenchmarkOperationDescriptor> descList)
            {
                _benchmark = benchmark;

                _state = new BenchmarkState();

                _results = new Dictionary <string, Result>(descList.Count);

                var totalWeight = 0;

                var ticksPerSlot = benchmark.ResultBucketInterval * Stopwatch.Frequency / 1000000;

                if (ticksPerSlot == 0)
                {
                    throw new Exception("Too low bucket interval: " + benchmark.ResultBucketInterval);
                }

                foreach (var desc in descList)
                {
                    _results[desc.Name] = new Result(benchmark.ResultBucketCount, ticksPerSlot);

                    totalWeight += desc.Weight;
                }

                _descs = new BenchmarkOperationDescriptor[totalWeight];

                var idx = 0;

                foreach (var desc in descList)
                {
                    for (var i = 0; i < desc.Weight; i++)
                    {
                        _descs[idx++] = desc;
                    }
                }
            }
Example #2
0
 /// <summary>
 /// Batch execution finished callback.
 /// </summary>
 /// <param name="state">State.</param>
 /// <param name="duration">Duration.</param>
 /// <returns>True if this result must be counted.</returns>
 protected virtual bool OnBatchFinished(BenchmarkState state, long duration)
 {
     return(true);
 }
Example #3
0
 /// <summary>
 /// Batch execution started callback.
 /// </summary>
 /// <param name="state">State.</param>
 protected virtual void OnBatchStarted(BenchmarkState state)
 {
     // No-op.
 }
Example #4
0
            /// <summary>
            /// Constructor.
            /// </summary>
            /// <param name="benchmark">Benchmark.</param>
            /// <param name="descList">Descriptor list.</param>
            public BenchmarkTask(BenchmarkBase benchmark,
                ICollection<BenchmarkOperationDescriptor> descList)
            {
                _benchmark = benchmark;

                _state = new BenchmarkState();

                _results = new Dictionary<string, Result>(descList.Count);

                var totalWeight = 0;

                var ticksPerSlot = benchmark.ResultBucketInterval*Stopwatch.Frequency/1000000;

                if (ticksPerSlot == 0)
                    throw new Exception("Too low bucket interval: " + benchmark.ResultBucketInterval);

                foreach (var desc in descList)
                {
                    _results[desc.Name] = new Result(benchmark.ResultBucketCount, ticksPerSlot);

                    totalWeight += desc.Weight;
                }

                _descs = new BenchmarkOperationDescriptor[totalWeight];

                var idx = 0;

                foreach (var desc in descList)
                {
                    for (var i = 0; i < desc.Weight; i++)
                        _descs[idx++] = desc;
                }
            }
Example #5
0
 /// <summary>
 /// Batch execution finished callback.
 /// </summary>
 /// <param name="state">State.</param>
 /// <param name="duration">Duration.</param>
 /// <returns>True if this result must be counted.</returns>
 protected virtual bool OnBatchFinished(BenchmarkState state, long duration)
 {
     return true;
 }
Example #6
0
 /// <summary>
 /// Batch execution started callback.
 /// </summary>
 /// <param name="state">State.</param>
 protected virtual void OnBatchStarted(BenchmarkState state)
 {
     // No-op.
 }