Skip to content

Instantly share code, notes, and snippets.

@misha354
Created January 22, 2019 21:26
Show Gist options
  • Save misha354/f82ca3ddb91b050148496f539c8a36cc to your computer and use it in GitHub Desktop.
Save misha354/f82ca3ddb91b050148496f539c8a36cc to your computer and use it in GitHub Desktop.
/*
Based on Brendan Gregg's work: http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html
*/
global s;
global quit = 0;
probe timer.profile {
if (pid() == target()) {
if (quit) {
foreach (i in s-) {
print_stack(i);
printf("\t%d\n", @count(s[i]));
}
exit()
} else {
s[ubacktrace()] <<< 1;
}
}
}
probe timer.s(20) {
quit = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment