Beispiel #1
0
        /// <summary>
        /// Runs this benchmark and returns result information.
        /// </summary>
        public BenchmarkResult Run()
        {
            // Prepare
            this.Prepare();

            // Setup benchmark result and start initial label
            BenchmarkResult res = new BenchmarkResult();

            res.BeginLabel("Profiling");

            // Run benchmark
            this.RunBenchmark(res);

            // End label
            res.EndLabel();
            res.Finish();

            // Post process
            PostProcessResult(ref res);
            return(res);
        }
Beispiel #2
0
 /// <summary>
 /// Can be overridden to post process the benchmarking result generated by <see cref="Run"/>.
 /// This can for example to be used to register processing overhead to the result.
 /// </summary>
 /// <param name="result">The result to post process. Can either be modified or fully overwritten.</param>
 protected virtual void PostProcessResult(ref BenchmarkResult result)
 {
 }
Beispiel #3
0
 /// <summary>
 /// Execute your benchmarking code in here.
 /// Important: Since this is just a simple <see cref="System.Diagnostics.Stopwatch"/> measurement, you need take possible overhead in your benchmarking code into account.
 /// The benchmark will simply record the amount of time it takes to call this method!
 ///
 /// It is good practice to run multiple iterations of the operation you want to profile to achieve more "stable" / reliable results.
 /// </summary>
 /// <param name="bRes">The benchmarking result class that can be used to start more labels. When it is passed in, it will already be in the first label named by the class implementing this benchmark base class.</param>
 protected abstract void RunBenchmark(BenchmarkResult bRes);