LoginSignup
0

More than 5 years have passed since last update.

Ruby C拡張でプロファイルをとる

Posted at

google-perftools を使うのがおすすめ.

sudo aptitude install libgoogle-perftools-dev

$ LD_PRELOAD=/usr/lib/libprofiler.so > profile.out ruby examples/hoge.rb 
^CBye.
PROFILE: interrupts/evictions/bytes = 12/0/164
$ google-pprof --dot `which ruby` ./profile.out > prof.dot
Using local file /usr/local/bin/ruby.
Using local file ./profile.out.
$ dot -T png prof.dot > prof.png
$ eog prof.png 

部分的に取得したいとき

#include "google/profiler.h"

//とりたいとこでかく
ProfilerStart("profile.out");
...
ProfilerStop();

callgrind でみたいとき

$ sudo aptitude install kcachegrind
$ google-pprof --callgrind `which ruby` ./profile.out > prof.callgrind

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0