OSX 默认就安装了 dtrace,结果:
➜ ~ dtrace -n BEGINdtrace: failed to initialize dtrace: DTrace requires additional privileges
搜了一下居然仅仅是:
➜ ~ sudo chmod u+s /usr/sbin/dtrace
生成一个测试文件,/tmp/hello.d:
BEGIN{ trace("hello, world"); exit(0);}
执行性能跟踪:
➜ ~ dtrace -s /tmp/hello.ddtrace: script '/tmp/hello.d' matched 1 probeCPU ID FUNCTION:NAME 0 1 :BEGIN hello, world