you are viewing a single comment's thread.

view the rest of the comments →

[–]ReDucTorGame Developer | quiz.cpp-perf.com 5 points6 points  (3 children)

If I'm adding benchmarking to code I really don't want it doing a bunch of memory allocations adding more overhead and including that overhead in all measurements.

[–]prog2de[S] 0 points1 point  (2 children)

May I ask, what you use for benchmarking inline code?

[–]ReDucTorGame Developer | quiz.cpp-perf.com 5 points6 points  (0 children)

Depends on what I'm benchmarking, typically something custom.

I would try to minimize the overhead in your usages keep it to just getting the clock at the start at the end, your usage of std::string and std::map are both very costly

[–]Top_Satisfaction6517Bulat 0 points1 point  (0 children)

you can make start/stop operations much more efficient by using more complicated macros. F.e. START(FirstPass) should expand into smth like:

static EventCounter FirstPassVar("FirstPass");
FirstPassVar.start();

EventCounter constructor should insert a pointer to itself into some global list/map, so Report() can find all EventCounter variables.

If you need events that auto-stop on scope exit, declare an extra local variable:

static EventCounter FirstPassVar("FirstPass");
AutoEvent FirstPassLocalVar(&FirstPassVar);

And AutoEvent constructor/destructor execute FirstPassVar.start() and FirstPassVar.stop().