Skip to content

Instantly share code, notes, and snippets.

@misha354
Created January 22, 2019 21:29
Show Gist options
  • Save misha354/31b2eb3f83803a163b3e6b6ce72df1c9 to your computer and use it in GitHub Desktop.
Save misha354/31b2eb3f83803a163b3e6b6ce72df1c9 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