0

The application workflow is something like this:

init();
while(packet.read()) {
    if (filterpacket(packet)) 
       process(packet); // function to benchmark.
}

Over the course of one full application run, I need the measure the time of process(packet). Individually calling process(packet) in google benchmark won't work because process would change some internal data structure which will affect the timings of the next process(packet) called. It seems also counter-intuitive to make fixtures for each internal state.

How do I do this with google benchmark?

I know I can simply make some ifdefs/flags and make application version that measures the time taken by process(packet) but that would defeat the purpose of google benchmark. My expected time of the process(packet) is too small, of the order of 200ns.

themagicalyang
  • 2,493
  • 14
  • 21
  • IMO not enough data to help. Also `process` is to fast to be reliable measurable by google benchmark (in such cases it is easy to create benchmark which will measure something else), I suspect you need some other more advanced means to measure your performance especially that the network is involved. – Marek R Dec 11 '19 at 10:40
  • I can mock the packet.read() to read from file for benchmarking purposes. And google benchmark does well for ~100ns function benchmarking. But yes, one needs to be careful not to introduce other variables that can tamper the benchmark with such low numbers – themagicalyang Dec 11 '19 at 10:43
  • Take a [look on that](https://youtu.be/NH1Tta7purM). – Marek R Dec 11 '19 at 11:08

0 Answers0