Skip to content

Commit 77fa9d0

Browse files
author
(no author)
committed
This commit was manufactured by cvs2svn to create tag 'v1_1d1'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_1d1@369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 6d58357 commit 77fa9d0

File tree

6 files changed

+2617
-33
lines changed

6 files changed

+2617
-33
lines changed

ext/tkutil/MANIFEST

Lines changed: 0 additions & 3 deletions
This file was deleted.

ext/tkutil/depend

Lines changed: 0 additions & 1 deletion
This file was deleted.

ext/tkutil/tkutil.c

Lines changed: 0 additions & 29 deletions
This file was deleted.

lib/profile.rb

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
module Profiler__
3+
Start = Float(Time.times[0])
4+
top = "toplevel".intern
5+
Stack = [[0, 0, top]]
6+
MAP = {top => [1, 0, 0, "#toplevel"]}
7+
8+
p = proc{|event, file, line, id, binding, klass|
9+
case event
10+
when "call", "c-call"
11+
now = Float(Time.times[0])
12+
Stack.push [now, 0.0, id]
13+
when "return", "c-return"
14+
now = Float(Time.times[0])
15+
tick = Stack.pop
16+
data = MAP[id]
17+
unless data
18+
name = klass.to_s
19+
if klass.kind_of? Class
20+
name += "#"
21+
else
22+
name += "."
23+
end
24+
data = [0, 0, 0, name+id.id2name]
25+
MAP[id] = data
26+
end
27+
data[0] += 1
28+
cost = now - tick[0]
29+
data[1] += cost
30+
data[2] += cost - tick[1]
31+
Stack[-1][1] += cost
32+
end
33+
}
34+
END {
35+
set_trace_func nil
36+
total = Float(Time.times[0]) - Start
37+
MAP[:toplevel][1] = total
38+
# f = open("./rmon.out", "w")
39+
f = STDERR
40+
data = MAP.values.sort!{|a,b| b[2] <=> a[2]}
41+
sum = 0
42+
f.printf " %% cumulative self self total\n"
43+
f.printf " time seconds seconds calls ms/call ms/call name\n"
44+
for d in data
45+
sum += d[2]
46+
f.printf "%6.2f %8.2f %8.2f %8d ", d[2]/total*100, sum, d[2], d[0]
47+
f.printf "%8.2f %8.2f %s\n", d[2]*1000/d[0], d[1]*1000/d[0], d[3]
48+
end
49+
p total
50+
f.close
51+
}
52+
set_trace_func p
53+
end

0 commit comments

Comments
 (0)