Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can I calculate throughput via google benchmark library in C++

I want to measure how many times C++ function will be executed per N seconds, is there a way to do that via google benchmark? Maybe using some lambda for ComputeStatistics function?

If there is no way to do it via google benchmark: are there any other ways of measuring throughput?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The throughput is reported in units of items/s
https://github.com/google/benchmark/blob/main/docs/user_guide.md#output-formats

Benchmark                Time(ns)    CPU(ns) Iterations
-------------------------------------------------------
BM_SetInsert/1024/1         28928      29349      23853  133.097kB/s   33.2742k items/s
BM_SetInsert/1024/8         32065      32913      21375  949.487kB/s   237.372k items/s
BM_SetInsert/1024/10        33157      33648      21431  1.13369MB/s   290.225k items/s

So to directly answer your question

I want to measure how many times C++ function will be executed per N seconds

you would take this items/s and multiply by N seconds, that would give you approximately the number of items processed in N seconds.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading