timbunce / devel-nytprof

Devel::NYTProf is a powerful feature-rich source code profiler for Perl. (Mostly in maintenance mode, so PRs are much more likely to be acted upon than Issues.)
http://blog.timbunce.org/tag/nytprof/
68 stars 51 forks source link

Enhancement request: flamegraph colors #22

Open PenelopeFudd opened 10 years ago

PenelopeFudd commented 10 years ago

If you run the same program the same way, the flame graph looks the same... except for the colors! I'm running programs and making changes, and I'm never quite sure if two flame graphs are equivalent.

Underneath the flame graph, there's a warning that says the colors and x-axis position are not meaningful, but that's not exactly true. The x-axis has function names sorted alphabetically at each level of the stack; the result is a canonical ordering of the information that allows graphs to be compared in a meaningful way. The same could be done with color, where instead of random coloring, the random number generator could be given a fixed seed, or replaced with a counter (modulo the number of colors).

That way, you could flick back and forth between two tabs and see at a glance that since all the colors are the same and the shape is the same, the call graph must be the same. Adding or removing a single call would completely change the coloring of the graph.

For extra bonus karma, if only part of the graph has changed, then only that part should change colors, but that's more complicated than replacing the random number generator; the colors in the call stack would depend on the color of the level below them.

Cheers!

timbunce commented 10 years ago

Interesting idea. Should be easy for you to try out and send me a pull request ;)

timbunce commented 9 years ago

See the new --cp option. The new --hash option might also work well and would be simpler (because it doesn't require copying the pallet file between runs).