用于 Ruby 的线程分析器
gem install rblineprof
或者在您的 Gemfile 中:
gem 'rblineprof'
require 'rblineprof'
profile = lineprof(/./) do
sleep 0.001
100.times do
sleep 0.001
1*2*3
4*5*6
7*8*9*10*11*12*13*14*15
2**32
2**128
end
end
file = profile.keys.first
File.readlines(file).each_with_index do |line, num|
wall, cpu, calls, allocations = profile[file][num + 1]
if wall > 0 || cpu > 0 || calls > 0
printf(
"% 5.1fms + % 6.1fms (% 4d) | %s",
cpu / 1000.0,
(wall - cpu) / 1000.0,
calls,
line
)
else
printf " | %s", line
end
end我会给你:
…rblineprof 遵循 MIT 许可证 发布。
暂无开放 Issues,或尚未同步最近议题。