Thanks for making this public, I was about to do the same thing. :)
First few tests do suffer from "spin up" time of cpu ). Adding (some crappy code) to perform a dummy while loop for a second will knock about 20% time off the initial results.
eg:
int main(void) {
auto start = std::chrono::steady_clock::now();
long total = 0;
while (true) {
auto later = std::chrono::steady_clock::now();
if (later - start > std::chrono::milliseconds(1000)) {
break;
}
total++;
}
printf("Starting\n");
...
On i7-6900K, ubuntu 17.10
Without spinup
Performance of std::chrono::steady_clock
Average time per call: 20.1 ns
Clock tick period: 1.0 ns
Measured resolution: 18.0 ns (median: 20.0 ns) (sigma: 8.7 ns) (average: 20.1 +/- 0.1 ns)
Performance of std::chrono::system_clock
Average time per call: 20.3 ns
Clock tick period: 1.0 ns
Measured resolution: 19.0 ns (median: 20.0 ns) (sigma: 17.1 ns) (average: 20.3 +/- 0.1 ns)
Performance of std::chrono::high_resolution_clock
Average time per call: 19.1 ns
Clock tick period: 1.0 ns
Measured resolution: 14.0 ns (median: 20.0 ns) (sigma: 18.1 ns) (average: 19.1 +/- 0.1 ns)
With spinup:
Performance of std::chrono::steady_clock
Average time per call: 16.1 ns
Clock tick period: 1.0 ns
Measured resolution: 15.0 ns (median: 16.0 ns) (sigma: 6.3 ns) (average: 16.1 +/- 0.1 ns)
Performance of std::chrono::system_clock
Average time per call: 16.3 ns
Clock tick period: 1.0 ns
Measured resolution: 15.0 ns (median: 16.0 ns) (sigma: 8.2 ns) (average: 16.3 +/- 0.1 ns)
Performance of std::chrono::high_resolution_clock
Average time per call: 16.3 ns
Clock tick period: 1.0 ns
Measured resolution: 15.0 ns (median: 16.0 ns) (sigma: 9.7 ns) (average: 16.3 +/- 0.1 ns)
Thanks for making this public, I was about to do the same thing. :)
First few tests do suffer from "spin up" time of cpu ). Adding (some crappy code) to perform a dummy while loop for a second will knock about 20% time off the initial results.
eg:
On i7-6900K, ubuntu 17.10
Without spinup
Performance of std::chrono::steady_clock
Average time per call: 20.1 ns
Clock tick period: 1.0 ns
Measured resolution: 18.0 ns (median: 20.0 ns) (sigma: 8.7 ns) (average: 20.1 +/- 0.1 ns)
Performance of std::chrono::system_clock
Average time per call: 20.3 ns
Clock tick period: 1.0 ns
Measured resolution: 19.0 ns (median: 20.0 ns) (sigma: 17.1 ns) (average: 20.3 +/- 0.1 ns)
Performance of std::chrono::high_resolution_clock
Average time per call: 19.1 ns
Clock tick period: 1.0 ns
Measured resolution: 14.0 ns (median: 20.0 ns) (sigma: 18.1 ns) (average: 19.1 +/- 0.1 ns)
With spinup:
Performance of std::chrono::steady_clock
Average time per call: 16.1 ns
Clock tick period: 1.0 ns
Measured resolution: 15.0 ns (median: 16.0 ns) (sigma: 6.3 ns) (average: 16.1 +/- 0.1 ns)
Performance of std::chrono::system_clock
Average time per call: 16.3 ns
Clock tick period: 1.0 ns
Measured resolution: 15.0 ns (median: 16.0 ns) (sigma: 8.2 ns) (average: 16.3 +/- 0.1 ns)
Performance of std::chrono::high_resolution_clock
Average time per call: 16.3 ns
Clock tick period: 1.0 ns
Measured resolution: 15.0 ns (median: 16.0 ns) (sigma: 9.7 ns) (average: 16.3 +/- 0.1 ns)