Skip to content

Instantly share code, notes, and snippets.

@Watson1978
Created November 20, 2012 12:34
Show Gist options
  • Save Watson1978/4117667 to your computer and use it in GitHub Desktop.
Save Watson1978/4117667 to your computer and use it in GitHub Desktop.
#!/usr/sbin/dtrace -s
#pragma D option quiet
BEGIN
{
printf("Target pid: %d\n\n", $target);
}
macruby$target:::method-entry
{
/* printf("%30s:%-5d %s#%s\n", copyinstr(arg2), arg3,
copyinstr(arg0), copyinstr(arg1));
*/
@methods_count[copyinstr(arg0), copyinstr(arg1)] = count();
}
END
{
printf("\n");
printf("%30s %-30s %s\n", "CLASS", "METHOD", "COUNT");
printf("--------------------------------------------------------------------------------\n");
printa("%30s %-30s %@d\n", @methods_count);
}
@Watson1978
Copy link
Author

MacRuby と同じ DTrace のプローブを使うことができます。
https://github.com/MacRuby/MacRuby/wiki/Using-DTrace

@Watson1978
Copy link
Author

アプリを終了させると、dtrace の結果が表示されます。

@Watson1978
Copy link
Author

dtrace のサンプルは
https://github.com/MacRuby/MacRubySamples/tree/master/DTrace
にいくつかあります。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment