jcward / hxtelemetry

Haxe Telemetry Generator for hxScout
MIT License
61 stars 13 forks source link

Numer of times called for functions in Profiler #63

Open giuppe opened 5 years ago

giuppe commented 5 years ago

Is it possible to show for each function, in the Profiler screen, the number of times called? It could be helpful for finding the types of bugs where the code wrongly calls many times an expensive function.

jcward commented 5 years ago

Hi - the profiler used is a sampling profiler, so it probes the call stack at a given time interval (as opposed to every time the stack changes). So it doesn't actually count invocations, but reports what spends the most time on the stack on average.

However, I believe the library might also support (or maybe it's a WIP, I'd have to dig into the code to recall) sending events / counters. So you could perhaps instrument functions with counters manually, if you wanted to. It's just not automatic.

But the theory of the sampling profiler is, if it's an expensive function being called too much, it'll show up because of the time it takes.

giuppe commented 5 years ago

Hi! Thanks for your answer.

the profiler used is a sampling profiler, so it probes the call stack at a given time interval (as opposed to every time the stack changes). So it doesn't actually count invocations, but reports what spends the most time on the stack on average.

How does it counts allocations? It seems a similar problem. Maybe there are some sort of metadata on the hxcpp side?

However, I believe the library might also support (or maybe it's a WIP, I'd have to dig into the code to recall) sending events / counters. So you could perhaps instrument functions with counters manually, if you wanted to. It's just not automatic.

This would be good! Any pointers on how to do it?

But the theory of the sampling profiler is, if it's an expensive function being called too much, it'll show up because of the time it takes.

My use case is this: once you see that the last function you can control (that is, in your code) on the stack (for example, a drawing function from a framework like OpenFL) is taking X msecs, how to discriminate between the cases where:

Also in the second case it could show no problem on my developer hardware, but showing up on the low-end hardware of some of my player (or worst, on some mobile gpu).

There is a way to discriminate between the two cases with the parameters that we have now?