benchmarkResume

Suspends and resumes the current benchmark, respectively. This is useful if the benchmark needs to set things up before performing the measurement.

  1. void benchmarkSuspend()
  2. void benchmarkResume()
    void
    benchmarkResume
    ()

Examples

1 import std.algorithm;
2 void benchmark_findDouble(uint n)
3 {
4     // Fill an array of random numbers and an array of random indexes
5     benchmarkSuspend();
6     auto array = new double[n];
7     auto indexes = new size_t[n];
8     foreach (i; 0 .. n)
9     {
10         array[i] = uniform(0.0, 1000.0);
11         indexes[i] = uniform(0, n);
12     }
13     benchmarkResume();
14 
15     // The actual benchmark begins here
16     foreach (i; 0 .. n)
17     {
18         auto balance = std.algorithm.find(array, array[indexes[i]]);
19     }
20 }
21 unittest
22 {
23     TODO writeln(benchmark!benchmark_findDouble(10_000).to!("msecs", uint));
24 }

Meta