MCPcopy Create free account
hub / github.com/p-ranav/tabulate / time_ms

Function time_ms

samples/benchmark.cpp:24–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22// estimate of the true cost -- a single sample is too noisy to compare
23// scenarios that differ by only a few percent.
24template <typename Fn> double time_ms(Fn &&fn, int repeats = 5) {
25 double best = -1.0;
26 for (int i = 0; i < repeats; ++i) {
27 auto start = std::chrono::steady_clock::now();
28 fn();
29 double ms = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - start).count();
30 if (best < 0.0 || ms < best)
31 best = ms;
32 }
33 return best;
34}
35
36std::string ms_str(double ms) {
37 std::ostringstream out;

Callers 5

benchmark_scalingFunction · 0.85
benchmark_feature_costsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected