Profile Ruby 2.0 apps using DTrace - part 2
crypt.codemancers.com
crypt.codemancers.com
rails c 2>&1 | tee profile.txt
require 'profile'
SomeClass.some_method
exit (or ctrl-d)
grep -E "SomeClass\#|cumulative self|seconds call" profile.txt
Example of results: % cumulative self self total
time seconds seconds calls ms/call ms/call name
1.05 0.79 0.01 5 2.00 2.00 SomeClass#_validate_callbacks
0.00 0.95 0.00 13 0.00 0.00 SomeClass#_create_callbacks
0.00 0.95 0.00 13 0.00 0.00 SomeClass#_update_callbacks
0.00 0.95 0.00 15 0.00 0.00 SomeClass#reflections
0.00 0.95 0.00 12 0.00 0.00 SomeClass#_save_callbacks
...
Other things to look at:* Benchmark: http://www.ruby-doc.org/stdlib-1.9.3/libdoc/benchmark/rdoc/B...
* Rails perf testing: http://guides.rubyonrails.org/performance_testing.html
* Ruby-prof: https://github.com/rdp/ruby-prof
* Tracer: http://www.ruby-doc.org/stdlib-1.9.3/libdoc/tracer/rdoc/inde...
* TracePoint: https://github.com/rubyunworks/tracepoint
* Autolog: https://github.com/garysweaver/autolog
* set_trace_func: http://apidock.com/ruby/Kernel/set_trace_func