ruby-prof 0.4.0-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +17 -0
- data/LICENSE +23 -0
- data/README +220 -0
- data/Rakefile +141 -0
- data/bin/ruby-prof +154 -0
- data/doc/classes/RubyProf.html +563 -0
- data/doc/classes/RubyProf/CallInfo.html +274 -0
- data/doc/classes/RubyProf/FlatPrinter.html +207 -0
- data/doc/classes/RubyProf/GraphHtmlPrinter.html +538 -0
- data/doc/classes/RubyProf/GraphPrinter.html +240 -0
- data/doc/classes/RubyProf/MethodInfo.html +556 -0
- data/doc/classes/RubyProf/ProfileTask.html +395 -0
- data/doc/classes/RubyProf/Result.html +234 -0
- data/doc/created.rid +1 -0
- data/doc/files/LICENSE.html +142 -0
- data/doc/files/README.html +376 -0
- data/doc/files/bin/ruby-prof.html +143 -0
- data/doc/files/examples/flat_txt.html +187 -0
- data/doc/files/examples/graph_html.html +948 -0
- data/doc/files/examples/graph_txt.html +305 -0
- data/doc/files/ext/ruby_prof_c.html +101 -0
- data/doc/files/lib/ruby-prof/flat_printer_rb.html +101 -0
- data/doc/files/lib/ruby-prof/graph_html_printer_rb.html +108 -0
- data/doc/files/lib/ruby-prof/graph_printer_rb.html +101 -0
- data/doc/files/lib/ruby-prof/profiletask_rb.html +109 -0
- data/doc/files/lib/ruby-prof_rb.html +111 -0
- data/doc/files/lib/unprof_rb.html +108 -0
- data/doc/fr_class_index.html +34 -0
- data/doc/fr_file_index.html +39 -0
- data/doc/fr_method_index.html +67 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/examples/flat.txt +57 -0
- data/examples/graph.html +827 -0
- data/examples/graph.txt +171 -0
- data/ext/extconf.rb +19 -0
- data/ext/ruby_prof.c +1433 -0
- data/lib/ruby-prof.rb +38 -0
- data/lib/ruby-prof/flat_printer.rb +76 -0
- data/lib/ruby-prof/graph_html_printer.rb +227 -0
- data/lib/ruby-prof/graph_printer.rb +142 -0
- data/lib/ruby-prof/profiletask.rb +150 -0
- data/lib/ruby_prof.so +0 -0
- data/lib/unprof.rb +8 -0
- data/test/basic_test.rb +141 -0
- data/test/clock_mode_test.rb +73 -0
- data/test/module_test.rb +45 -0
- data/test/prime.rb +58 -0
- data/test/prime_test.rb +24 -0
- data/test/printers_test.rb +28 -0
- data/test/recursive_test.rb +55 -0
- data/test/test.rb +3 -0
- data/test/test_helper.rb +45 -0
- data/test/test_suite.rb +9 -0
- data/test/thread_test.rb +32 -0
- data/test/timing_test.rb +90 -0
- metadata +122 -0
data/test/prime_test.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'ruby-prof'
|
5
|
+
require 'prime'
|
6
|
+
require 'test_helper'
|
7
|
+
|
8
|
+
|
9
|
+
# -- Tests ----
|
10
|
+
class PrimeTest < Test::Unit::TestCase
|
11
|
+
def test_consistency
|
12
|
+
result = RubyProf.profile do
|
13
|
+
run_primes
|
14
|
+
end
|
15
|
+
|
16
|
+
result.threads.values.each do |methods|
|
17
|
+
methods.values.each do |method|
|
18
|
+
check_parent_times(method)
|
19
|
+
check_parent_calls(method)
|
20
|
+
check_child_times(method)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'ruby-prof'
|
5
|
+
require 'prime'
|
6
|
+
require 'test_helper'
|
7
|
+
|
8
|
+
|
9
|
+
# -- Tests ----
|
10
|
+
class PrintersTest < Test::Unit::TestCase
|
11
|
+
def test_printer
|
12
|
+
result = RubyProf.profile do
|
13
|
+
run_primes
|
14
|
+
end
|
15
|
+
|
16
|
+
printer = RubyProf::FlatPrinter.new(result)
|
17
|
+
printer.print(STDOUT)
|
18
|
+
|
19
|
+
printer = RubyProf::GraphHtmlPrinter.new(result)
|
20
|
+
printer.print(STDOUT)
|
21
|
+
|
22
|
+
printer = RubyProf::GraphPrinter.new(result)
|
23
|
+
printer.print(STDOUT)
|
24
|
+
|
25
|
+
# we should get here
|
26
|
+
assert(true)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'ruby-prof'
|
5
|
+
require 'timeout'
|
6
|
+
require 'test_helper'
|
7
|
+
|
8
|
+
|
9
|
+
def simple(n)
|
10
|
+
sleep(1)
|
11
|
+
n -= 1
|
12
|
+
return if n == 0
|
13
|
+
simple(n)
|
14
|
+
end
|
15
|
+
|
16
|
+
def factorial(n)
|
17
|
+
if n < 2 then
|
18
|
+
n
|
19
|
+
else
|
20
|
+
n * factorial(n-1)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# -- Tests ----
|
26
|
+
class RecursiveTest < Test::Unit::TestCase
|
27
|
+
def test_recursive
|
28
|
+
result = RubyProf.profile do
|
29
|
+
simple(3)
|
30
|
+
end
|
31
|
+
|
32
|
+
result.threads.values.each do |methods|
|
33
|
+
methods.values.each do |method|
|
34
|
+
check_parent_times(method)
|
35
|
+
check_parent_calls(method)
|
36
|
+
check_child_times(method)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_factorial
|
42
|
+
result = RubyProf.profile do
|
43
|
+
# Around 700 on windows causes "stack level too deep" error
|
44
|
+
factorial(650)
|
45
|
+
end
|
46
|
+
|
47
|
+
result.threads.values.each do |methods|
|
48
|
+
methods.values.each do |method|
|
49
|
+
check_parent_times(method)
|
50
|
+
check_parent_calls(method)
|
51
|
+
check_child_times(method)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/test/test.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
def print_results(result)
|
2
|
+
printer = RubyProf::FlatPrinter.new(result)
|
3
|
+
printer.print(STDOUT)
|
4
|
+
|
5
|
+
STDOUT << "\n" * 2
|
6
|
+
|
7
|
+
printer = RubyProf::GraphPrinter.new(result)
|
8
|
+
printer.print(STDOUT)
|
9
|
+
end
|
10
|
+
|
11
|
+
def check_parent_times(method)
|
12
|
+
return if method.parents.length == 0
|
13
|
+
|
14
|
+
parents_self_time = method.parents.values.inject(0) do |sum, call_info|
|
15
|
+
sum + call_info.self_time
|
16
|
+
end
|
17
|
+
assert_in_delta(method.self_time, parents_self_time, 0.01, method.name)
|
18
|
+
|
19
|
+
parents_children_time = method.parents.values.inject(0) do |sum, call_info|
|
20
|
+
sum + call_info.children_time
|
21
|
+
end
|
22
|
+
assert_in_delta(method.children_time, parents_children_time, 0.01, method.name)
|
23
|
+
end
|
24
|
+
|
25
|
+
def check_parent_calls(method)
|
26
|
+
return if method.parents.length == 0
|
27
|
+
|
28
|
+
parent_calls = method.parents.values.inject(0) do |sum, call_info|
|
29
|
+
sum + call_info.called
|
30
|
+
end
|
31
|
+
assert_equal(method.called, parent_calls, method.name)
|
32
|
+
end
|
33
|
+
|
34
|
+
def check_child_times(method)
|
35
|
+
return if method.children.length == 0
|
36
|
+
|
37
|
+
children_total_time = method.children.values.inject(0) do |sum, call_info|
|
38
|
+
sum + call_info.total_time
|
39
|
+
end
|
40
|
+
|
41
|
+
assert_in_delta(method.children_time, children_total_time, 0.01, method.name)
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
|
data/test/test_suite.rb
ADDED
data/test/thread_test.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'ruby-prof'
|
5
|
+
require 'timeout'
|
6
|
+
require 'test_helper'
|
7
|
+
|
8
|
+
# -- Tests ----
|
9
|
+
class ThreadTest < Test::Unit::TestCase
|
10
|
+
def test_thread
|
11
|
+
RubyProf.start
|
12
|
+
|
13
|
+
begin
|
14
|
+
status = Timeout::timeout(2) do
|
15
|
+
while true
|
16
|
+
next
|
17
|
+
end
|
18
|
+
end
|
19
|
+
rescue Timeout::Error
|
20
|
+
end
|
21
|
+
|
22
|
+
result = RubyProf.stop
|
23
|
+
|
24
|
+
result.threads.values.each do |methods|
|
25
|
+
methods.values.each do |method|
|
26
|
+
check_parent_times(method)
|
27
|
+
check_parent_calls(method)
|
28
|
+
check_child_times(method)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/test/timing_test.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'ruby-prof'
|
5
|
+
require 'test_helper'
|
6
|
+
|
7
|
+
def method1
|
8
|
+
sleep(1)
|
9
|
+
end
|
10
|
+
|
11
|
+
def method2
|
12
|
+
sleep(2)
|
13
|
+
method1
|
14
|
+
end
|
15
|
+
|
16
|
+
def method3
|
17
|
+
sleep(3)
|
18
|
+
method2
|
19
|
+
method1
|
20
|
+
end
|
21
|
+
|
22
|
+
# Need to use wall time for this test due to the sleep calls
|
23
|
+
RubyProf::clock_mode = RubyProf::WALL_TIME
|
24
|
+
|
25
|
+
class TimingTest < Test::Unit::TestCase
|
26
|
+
|
27
|
+
def test_basic
|
28
|
+
result = RubyProf.profile do
|
29
|
+
method1
|
30
|
+
end
|
31
|
+
|
32
|
+
assert_equal(1, result.threads.length)
|
33
|
+
|
34
|
+
methods = result.threads.values.first
|
35
|
+
assert_equal(3, methods.length)
|
36
|
+
|
37
|
+
method = methods['#toplevel']
|
38
|
+
assert_not_nil(method)
|
39
|
+
assert_in_delta(1, method.total_time, 0.02)
|
40
|
+
assert_in_delta(0, method.self_time, 0.02)
|
41
|
+
assert_in_delta(1, method.called, 0.02)
|
42
|
+
assert_equal(0, method.parents.length)
|
43
|
+
assert_equal(1, method.children.length)
|
44
|
+
|
45
|
+
method = methods['Object#method1']
|
46
|
+
assert_not_nil(method)
|
47
|
+
assert_in_delta(1, method.total_time, 0.02)
|
48
|
+
assert_in_delta(0, method.self_time, 0.02)
|
49
|
+
assert_equal(1, method.called)
|
50
|
+
assert_equal(1, method.parents.length)
|
51
|
+
assert_equal(1, method.children.length)
|
52
|
+
|
53
|
+
sleep = methods['Kernel#sleep']
|
54
|
+
assert_not_nil(sleep)
|
55
|
+
assert_in_delta(1, sleep.total_time, 0.02)
|
56
|
+
assert_in_delta(1, sleep.self_time, 0.02)
|
57
|
+
assert_in_delta(0, sleep.children_time, 0.02)
|
58
|
+
assert_equal(1, sleep.called)
|
59
|
+
assert_equal(1, sleep.parents.length)
|
60
|
+
assert_equal(0, sleep.children.length)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_timings
|
64
|
+
result = RubyProf.profile do
|
65
|
+
method3
|
66
|
+
end
|
67
|
+
|
68
|
+
assert_equal(1, result.threads.length)
|
69
|
+
methods = result.threads.values.first
|
70
|
+
assert_equal(5, methods.length)
|
71
|
+
|
72
|
+
method = methods['#toplevel']
|
73
|
+
assert_not_nil(method)
|
74
|
+
assert_in_delta(7, method.total_time, 0.02)
|
75
|
+
assert_in_delta(0, method.self_time, 0.02)
|
76
|
+
assert_in_delta(7, method.children_time, 0.02)
|
77
|
+
assert_equal(1, method.called)
|
78
|
+
assert_equal(0, method.parents.length)
|
79
|
+
assert_equal(1, method.children.length)
|
80
|
+
|
81
|
+
method = methods['Object#method3']
|
82
|
+
assert_not_nil(method)
|
83
|
+
assert_in_delta(7, method.total_time, 0.02)
|
84
|
+
assert_in_delta(0, method.self_time, 0.02)
|
85
|
+
assert_in_delta(7, method.children_time, 0.02)
|
86
|
+
assert_equal(1, method.called)
|
87
|
+
assert_equal(1, method.parents.length)
|
88
|
+
assert_equal(3, method.children.length)
|
89
|
+
end
|
90
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: ruby-prof
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.4.0
|
7
|
+
date: 2006-06-21 01:45:45 -06:00
|
8
|
+
summary: Fast Ruby profiler
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: shugo@ruby-lang.org and cfis@savagexi.com
|
12
|
+
homepage: http://rubyforge.org/projects/ruby-prof/
|
13
|
+
rubyforge_project: ruby-prof
|
14
|
+
description: ruby-prof is a fast code profiler for Ruby. It is a C extension and therefore is many times faster than the standard Ruby profiler. It supports both flat and graph profiles. For each method, graph profiles show how long the method ran, which methods called it and which methods it called. RubyProf generate both text and html and can output it to standard out or to a file.
|
15
|
+
autorequire: ruby-prof
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.8.2
|
24
|
+
version:
|
25
|
+
platform: mswin32
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
authors:
|
29
|
+
- Shugo Maeda and Charlie Savage
|
30
|
+
files:
|
31
|
+
- Rakefile
|
32
|
+
- README
|
33
|
+
- LICENSE
|
34
|
+
- CHANGES
|
35
|
+
- bin/ruby-prof
|
36
|
+
- lib/ruby-prof
|
37
|
+
- lib/ruby-prof.rb
|
38
|
+
- lib/unprof.rb
|
39
|
+
- lib/ruby-prof/flat_printer.rb
|
40
|
+
- lib/ruby-prof/graph_html_printer.rb
|
41
|
+
- lib/ruby-prof/graph_printer.rb
|
42
|
+
- lib/ruby-prof/profiletask.rb
|
43
|
+
- examples/flat.txt
|
44
|
+
- examples/graph.html
|
45
|
+
- examples/graph.txt
|
46
|
+
- ext/extconf.rb
|
47
|
+
- ext/ruby_prof.c
|
48
|
+
- ext/win32
|
49
|
+
- doc/classes
|
50
|
+
- doc/created.rid
|
51
|
+
- doc/files
|
52
|
+
- doc/fr_class_index.html
|
53
|
+
- doc/fr_file_index.html
|
54
|
+
- doc/fr_method_index.html
|
55
|
+
- doc/index.html
|
56
|
+
- doc/rdoc-style.css
|
57
|
+
- doc/classes/RubyProf
|
58
|
+
- doc/classes/RubyProf.html
|
59
|
+
- doc/classes/RubyProf/CallInfo.html
|
60
|
+
- doc/classes/RubyProf/FlatPrinter.html
|
61
|
+
- doc/classes/RubyProf/GraphHtmlPrinter.html
|
62
|
+
- doc/classes/RubyProf/GraphPrinter.html
|
63
|
+
- doc/classes/RubyProf/MethodInfo.html
|
64
|
+
- doc/classes/RubyProf/ProfileTask.html
|
65
|
+
- doc/classes/RubyProf/Result.html
|
66
|
+
- doc/files/bin
|
67
|
+
- doc/files/examples
|
68
|
+
- doc/files/ext
|
69
|
+
- doc/files/lib
|
70
|
+
- doc/files/LICENSE.html
|
71
|
+
- doc/files/README.html
|
72
|
+
- doc/files/bin/ruby-prof.html
|
73
|
+
- doc/files/examples/flat_txt.html
|
74
|
+
- doc/files/examples/graph_html.html
|
75
|
+
- doc/files/examples/graph_txt.html
|
76
|
+
- doc/files/ext/ruby_prof_c.html
|
77
|
+
- doc/files/lib/ruby-prof
|
78
|
+
- doc/files/lib/ruby-prof_rb.html
|
79
|
+
- doc/files/lib/unprof_rb.html
|
80
|
+
- doc/files/lib/ruby-prof/flat_printer_rb.html
|
81
|
+
- doc/files/lib/ruby-prof/graph_html_printer_rb.html
|
82
|
+
- doc/files/lib/ruby-prof/graph_printer_rb.html
|
83
|
+
- doc/files/lib/ruby-prof/profiletask_rb.html
|
84
|
+
- test/basic_test.rb
|
85
|
+
- test/clock_mode_test.rb
|
86
|
+
- test/module_test.rb
|
87
|
+
- test/prime.rb
|
88
|
+
- test/prime_test.rb
|
89
|
+
- test/printers_test.rb
|
90
|
+
- test/recursive_test.rb
|
91
|
+
- test/test.rb
|
92
|
+
- test/test_helper.rb
|
93
|
+
- test/test_suite.rb
|
94
|
+
- test/thread_test.rb
|
95
|
+
- test/timing_test.rb
|
96
|
+
- lib/ruby_prof.so
|
97
|
+
test_files:
|
98
|
+
- test/test_helper.rb
|
99
|
+
- test/test_suite.rb
|
100
|
+
rdoc_options:
|
101
|
+
- --title
|
102
|
+
- ruby-prof
|
103
|
+
- --inline-source
|
104
|
+
- --line-numbers
|
105
|
+
- --main
|
106
|
+
- README
|
107
|
+
extra_rdoc_files:
|
108
|
+
- bin/ruby-prof
|
109
|
+
- examples/flat.txt
|
110
|
+
- examples/graph.txt
|
111
|
+
- examples/graph.html
|
112
|
+
- ext/ruby_prof.c
|
113
|
+
- README
|
114
|
+
- LICENSE
|
115
|
+
executables:
|
116
|
+
- ruby-prof
|
117
|
+
extensions: []
|
118
|
+
|
119
|
+
requirements: []
|
120
|
+
|
121
|
+
dependencies: []
|
122
|
+
|