google / benchmark

A microbenchmark support library
Apache License 2.0
8.61k stars 1.57k forks source link

Add `--benchmark_human_readable` flag #1607

Open DiegoKrupitza opened 1 year ago

DiegoKrupitza commented 1 year ago

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

dmah42 commented 1 year ago

"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

DiegoKrupitza commented 1 year ago

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

dmah42 commented 1 year ago

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

DexterIV commented 1 year ago

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 :)

dmah42 commented 1 year ago

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)