Basically I want to measure the time while traversing over a packet dump file. Looking at the google benchmark documentation, I have come with:
BENCHMARK_DEFINE_F(MyFixture, FooTest)(benchmark::State& state) {
for (auto _ : state) {
// read
if (readPacket() == NO_MORE_PACKET) {
break;
}
if (!isPacketOfConsideration()) {
continue;
}
// some extra bookkeeping code if required
time t1{};
processPacket();
time t2{};
state.SetIterationTime(t2 - t1);
}
}
BENCHMARK_REGISTER_F(MyFixture, Footest)->UseManualTime();
The above is a pseudocode which uses manual time to measure and set iteration time. The questions are basically:
- Can I
break
from the google benchmark's for loop on the state? - Can I
continue
the google benchmark's for loop on the state without setting iteration time?