emberian / hprof

A real-time hierarchical profiler
Boost Software License 1.0
80 stars 11 forks source link

Measuring timings over a longer duration #7

Open leod opened 9 years ago

leod commented 9 years ago

As I understand it, the time measurements in hprof are reset at the start of each frame. print_timing() will print the timings of just the last frame.

I think it could be useful to measure timings for a longer duration (e.g. 1 second), optionally. For one thing, this would possibly smooth out random fluctuations in the timings.

Secondly, in my use case, I have some functions that are called periodically (e.g. starting a new game tick 20 times a second), but not necessarily every frame. So in the print_timing() output, I'll get either 0% or the percentage of time in the last frame for these periodical functions. Here, I think it would be useful to instead get the time taken in e.g. the last second.

daniel-vainsencher commented 8 years ago

Wait what? ;)

In my case, also, what I care about is total time spent under a node, over all frames, not just the last frame. In fact, I had implicitly assumed this is what the crate does and was surprised at all those "1"s in the call counts.