double value contains 'm' at the end while printing in google benchmarks table

26 Views Asked by At

This is my Benchmark method.

static void BM_LRU(benchmark::State &state) {
    lru_cache* cache = lru_init(state.range(0));
    std::vector<int> pages = generateRandomPages(state.range(1));

    for (auto _ : state) {
        lru_put_array(cache, pages.data(), pages.size());
    }

    double hitRatio = lru_get_hit_ratio(cache);

    // std::cout<<hitRatio<<std::endl;
    state.counters["Hit Ratio"] = hitRatio;

    lru_destroy(cache);
}

I am calling this method by,

BENCHMARK(BM_LRU)->ArgsProduct({{3, 5, 10}, {1000, 10000, 100000}})->Unit(benchmark::kMillisecond);

When i run the benchmark file i get,

----------------------------------------------------------------------
Benchmark                 Time             CPU   Iterations  Hit Ratio
----------------------------------------------------------------------
BM_LRU/3/1000         0.232 ms        0.232 ms         3039          0
BM_LRU/5/1000         0.239 ms        0.239 ms         2903         4m
BM_LRU/10/1000        0.243 ms        0.243 ms         2898      0.013
BM_LRU/3/10000         2.33 ms         2.33 ms          301       2.4m
BM_LRU/5/10000         2.42 ms         2.42 ms          292       4.5m
BM_LRU/10/10000        2.45 ms         2.45 ms          287       9.1m
BM_LRU/3/100000        23.4 ms         23.4 ms           30      2.93m
BM_LRU/5/100000        24.2 ms         24.2 ms           29      5.02m
BM_LRU/10/100000       24.5 ms         24.5 ms           29    0.01006

When i printed the values it was fine but in the benchmark table a 'm' appears at the end for some values. How to solve this?

1

There are 1 best solutions below

1
273K On

The output behavior can't be changed. The printer of user counters calls HumanReadableNumber() that cannot be tuned like you want it. Values less than 0.01 are printed with the "m" suffix - "milli".