benchmark icon indicating copy to clipboard operation
benchmark copied to clipboard

Add `--benchmark_human_readable` flag

Open DiegoKrupitza opened this issue 2 years ago • 5 comments

Allows used to add a command line flag called --benchmark_human_readable. By adding this flag the arguments passed to benchmarks are formated in a human friendly format. This means that numbers that are the power of 2 are formatted as 2^x (e.g., 64 will be 2^6). For numbers that are the power of 10 a different formatting style is used. Numbers 0-999 no formatting is used. For numbers 1000-999999 the format k is used (e.g., 32000 -> 32k). This also works for millions and billions. For numbers greater than 999 billion no special formatting is used. The design is rather simple allowing to by easily extendable.

Closes: https://github.com/google/benchmark/issues/1006

DiegoKrupitza avatar Jun 07 '23 23:06 DiegoKrupitza

"test/human_readable_formatting_test.cc:34: CheckRun: Check `name == run.benchmark_name()' failed. expected BM_base_two_args/2^1 got BM_base_two_args/2" test is failing

dmah42 avatar Jun 08 '23 13:06 dmah42

I squashed all the commits into a single one such that there is only one commit to merge.

DiegoKrupitza avatar Jun 19 '23 17:06 DiegoKrupitza

I squashed all the commits into a single one such that there is only one commit to merge.

thanks.. i generally "squash and merge" anyway, but this means less editing of commit messages for me :D

dmah42 avatar Jun 20 '23 11:06 dmah42

im not a big fan of "human readable format". Id consider binary output to be not human readable but not base10 numbers. Asked chatgpt what it "thinks" about that and here is the answer: The current name "Human Readable Format" seems appropriate for describing the functionality of the option. However, if you are looking for an alternative name that captures the essence of the feature, you could consider something like "Formatted Number Display" or "Enhanced Numeric Representation." just a thing to consider :)

DexterIV avatar Jun 23 '23 22:06 DexterIV

im not a big fan of "human readable format". Id consider binary output to be not human readable but not base10 numbers. Asked chatgpt what it "thinks" about that and here is the answer: The current name "Human Readable Format" seems appropriate for describing the functionality of the option. However, if you are looking for an alternative name that captures the essence of the feature, you could consider something like "Formatted Number Display" or "Enhanced Numeric Representation." just a thing to consider :)

i think it's a pretty well-defined name at this point. df -h, for instance:

       -h, --human-readable
              print sizes in powers of 1024 (e.g., 1023M)

or du -h:

       -h, --human-readable
              print sizes in human readable format (e.g., 1K 234M 2G)

dmah42 avatar Jun 26 '23 10:06 dmah42