google / benchmark

A microbenchmark support library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove "preamble" from csv output?

nickaleks opened this issue · comments

Currently, when we want to benchmark output in a csv file, this "preamble" is inserted in the beginning.

2019-04-13 17:34:34
Running /home/path/to/exe
Run on (8 X 4000 MHz CPU s)
CPU Caches:
  L1 Data 32K (x4)
  L1 Instruction 32K (x4)
  L2 Unified 256K (x4)
  L3 Unified 8192K (x1)

This obviously trips up any csv parser and has to be removed each time the benchmark is run. This is annoying and would be great if it was possible to disable that output when using a structured output format.

Please note that CSV reporter is deprecated, and will be removed sometime in the future
Simple, correct solution: https://github.com/google/benchmark#output-files + JSON

It is very sad to hear that. CSV is a more native format for any statistical analysis tool. I know it's easy to get csv from JSON, but its just one more extra step.

True. Sadly CSV isn't quite flexible enough, in the end.
This isn't the first time that was discussed.

Did the JSON solution work?

We make a distinction between the output and error streams. The context is sent to the error stream while the run data is sent to the output stream. Are you writing to file by redirect in the shell or using the library to output to a file?

We make a distinction between the output and error streams. The context is sent to the error stream while the run data is sent to the output stream. Are you writing to file by redirect in the shell or using the library to output to a file?

Very interesting. I did look into that before original reply but it looked to me all those streams in the end were dumped into the same output. Looks like that isn't so for console reporter, but is so for file reporter.
That is, if you do

./bench --benchmark_format=csv --benchmark_out_format=csv --benchmark_out=real > out

you will get only the CSV in out, only "preambule" in console, and both the preambule and CSV in real..

ah. that might be a bug. perhaps we should ensure output goes to the file and stdout and error goes to stderr? :)

We make a distinction between the output and error streams. The context is sent to the error stream while the run data is sent to the output stream. Are you writing to file by redirect in the shell or using the library to output to a file?

I write directly to a file using --benchmark_out.

True. Sadly CSV isn't quite flexible enough, in the end.
This isn't the first time that was discussed.

Did the JSON solution work?

I've just manually removed the extra lines, since it was a one time job. Next time would definitely use JSON though. Thank you for the help.