ruby-prof 0.6.0-x86-mswin32-60 → 0.7.0-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/CHANGES +54 -1
  2. data/README +134 -7
  3. data/Rakefile +40 -58
  4. data/bin/ruby-prof +21 -6
  5. data/ext/extconf.rb +13 -0
  6. data/ext/measure_allocations.h +16 -1
  7. data/ext/measure_cpu_time.h +15 -3
  8. data/ext/measure_gc_runs.h +76 -0
  9. data/ext/measure_gc_time.h +57 -0
  10. data/ext/measure_memory.h +61 -2
  11. data/ext/measure_process_time.h +13 -2
  12. data/ext/measure_wall_time.h +12 -1
  13. data/ext/mingw/Rakefile +23 -0
  14. data/ext/mingw/build.rake +38 -0
  15. data/ext/mingw/ruby_prof.so +0 -0
  16. data/ext/ruby_prof.c +685 -633
  17. data/ext/ruby_prof.h +188 -0
  18. data/ext/vc/ruby_prof.sln +20 -0
  19. data/ext/vc/ruby_prof.vcproj +241 -0
  20. data/ext/version.h +4 -0
  21. data/lib/ruby-prof.rb +4 -0
  22. data/lib/ruby-prof/call_info.rb +47 -0
  23. data/lib/ruby-prof/call_tree_printer.rb +9 -1
  24. data/lib/ruby-prof/graph_html_printer.rb +6 -5
  25. data/lib/ruby-prof/graph_printer.rb +3 -2
  26. data/lib/ruby-prof/method_info.rb +85 -0
  27. data/lib/ruby-prof/task.rb +1 -2
  28. data/lib/ruby-prof/test.rb +148 -0
  29. data/rails/environment/profile.rb +24 -0
  30. data/rails/example/example_test.rb +9 -0
  31. data/rails/profile_test_helper.rb +21 -0
  32. data/test/basic_test.rb +173 -80
  33. data/test/duplicate_names_test.rb +2 -3
  34. data/test/exceptions_test.rb +15 -0
  35. data/test/exclude_threads_test.rb +54 -0
  36. data/test/line_number_test.rb +18 -14
  37. data/test/measurement_test.rb +121 -0
  38. data/test/module_test.rb +5 -8
  39. data/test/no_method_class_test.rb +4 -5
  40. data/test/prime.rb +3 -5
  41. data/test/prime_test.rb +1 -12
  42. data/test/printers_test.rb +10 -13
  43. data/test/profile_unit_test.rb +10 -12
  44. data/test/recursive_test.rb +202 -92
  45. data/test/singleton_test.rb +1 -2
  46. data/test/stack_test.rb +138 -0
  47. data/test/start_stop_test.rb +95 -0
  48. data/test/test_suite.rb +7 -3
  49. data/test/thread_test.rb +111 -87
  50. data/test/unique_call_path_test.rb +206 -0
  51. metadata +42 -44
  52. data/ext/extconf.rb.rej +0 -13
  53. data/lib/ruby-prof/call_tree_printer.rb.rej +0 -27
  54. data/lib/ruby-prof/profile_test_case.rb +0 -80
  55. data/lib/ruby_prof.so +0 -0
  56. data/rails_plugin/ruby-prof/init.rb +0 -8
  57. data/rails_plugin/ruby-prof/lib/profiling.rb +0 -57
  58. data/test/measure_mode_test.rb +0 -79
  59. data/test/prime1.rb +0 -17
  60. data/test/prime2.rb +0 -26
  61. data/test/prime3.rb +0 -17
  62. data/test/start_test.rb +0 -24
  63. data/test/test_helper.rb +0 -55
  64. data/test/timing_test.rb +0 -133
@@ -1,17 +0,0 @@
1
-
2
- def make_random_array(length, maxnum)
3
- result = Array.new(length)
4
- result.each_index do |i|
5
- result[i] = rand(maxnum)
6
- end
7
-
8
- result
9
- end
10
-
11
- def is_prime(x)
12
- y = 2
13
- y.upto(x-1) do |i|
14
- return false if (x % i) == 0
15
- end
16
- true
17
- end
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'ruby-prof'
5
-
6
-
7
- def start
8
- RubyProf.start
9
- end
10
-
11
- def wait_around
12
- sleep(2)
13
- end
14
-
15
- def stop
16
- RubyProf.stop
17
- end
18
-
19
- start
20
- wait_around
21
- result = stop
22
-
23
- printer = RubyProf::FlatPrinter.new(result)
24
- printer.print(STDOUT)
@@ -1,55 +0,0 @@
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.inject(0) do |sum, call_info|
15
- sum + call_info.self_time
16
- end
17
-
18
- assert_in_delta(method.self_time, parents_self_time, 0.01,
19
- "Invalid parent times for method #{method.full_name}")
20
-
21
- parents_wait_time = method.parents.inject(0) do |sum, call_info|
22
- sum + call_info.wait_time
23
- end
24
-
25
- assert_in_delta(method.wait_time, parents_wait_time, 0.01, method.full_name)
26
-
27
- parents_children_time = method.parents.inject(0) do |sum, call_info|
28
- sum + call_info.children_time
29
- end
30
-
31
- assert_in_delta(method.children_time, parents_children_time, 0.01,
32
- "Invalid child times for method #{method.full_name}")
33
- end
34
-
35
- def check_parent_calls(method)
36
- return if method.parents.length == 0
37
-
38
- parent_calls = method.parents.inject(0) do |sum, call_info|
39
- sum + call_info.called
40
- end
41
-
42
- assert_equal(method.called, parent_calls,
43
- "Invalid parent calls for method #{method.full_name}")
44
- end
45
-
46
- def check_child_times(method)
47
- return if method.children.length == 0
48
-
49
- children_total_time = method.children.inject(0) do |sum, call_info|
50
- sum + call_info.total_time
51
- end
52
-
53
- assert_in_delta(method.children_time, children_total_time, 0.01,
54
- "Invalid child time for method #{method.full_name}")
55
- end
@@ -1,133 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'ruby-prof'
5
- require 'test_helper'
6
-
7
- # Need to use wall time for this test due to the sleep calls
8
- RubyProf::measure_mode = RubyProf::WALL_TIME
9
-
10
- def method1
11
- sleep(1)
12
- end
13
-
14
- def method2
15
- sleep(2)
16
- method1
17
- end
18
-
19
- def method3
20
- sleep(3)
21
- method2
22
- method1
23
- end
24
-
25
-
26
- class TimingTest < Test::Unit::TestCase
27
-
28
- def test_basic
29
- result = RubyProf.profile do
30
- method1
31
- end
32
- print_results(result)
33
-
34
- assert_equal(1, result.threads.length)
35
-
36
- methods = result.threads.values.first
37
- assert_equal(3, methods.length)
38
-
39
-
40
- methods = methods.sort.reverse
41
-
42
- method = methods[0]
43
- assert_equal('TimingTest#test_basic', method.full_name)
44
- assert_in_delta(1, method.total_time, 0.02)
45
- assert_in_delta(0, method.self_time, 0.02)
46
- assert_in_delta(0, method.wait_time, 0.02)
47
- assert_in_delta(1, method.children_time, 0.02)
48
- assert_equal(0, method.called)
49
- assert_equal(0, method.parents.length)
50
- assert_equal(1, method.children.length)
51
-
52
- method = methods[1]
53
- assert_equal('Object#method1', method.full_name)
54
- assert_in_delta(1, method.total_time, 0.02)
55
- assert_in_delta(0, method.self_time, 0.02)
56
- assert_in_delta(0, method.wait_time, 0.02)
57
- assert_equal(1, method.called)
58
- assert_equal(1, method.parents.length)
59
- assert_equal(1, method.children.length)
60
-
61
- method = methods[2]
62
- assert_equal('Kernel#sleep', method.full_name)
63
- assert_in_delta(1, method.total_time, 0.02)
64
- assert_in_delta(1, method.self_time, 0.02)
65
- assert_in_delta(0, method.wait_time, 0.02)
66
- assert_in_delta(0, method.children_time, 0.02)
67
- assert_equal(1, method.called)
68
- assert_equal(1, method.parents.length)
69
- assert_equal(0, method.children.length)
70
- end
71
-
72
- def test_timings
73
- result = RubyProf.profile do
74
- method3
75
- end
76
-
77
- assert_equal(1, result.threads.length)
78
- methods = result.threads.values.first
79
- assert_equal(5, methods.length)
80
-
81
- methods = methods.sort.reverse
82
-
83
- method = methods[0]
84
- assert_equal('TimingTest#test_timings', method.full_name)
85
- assert_in_delta(7, method.total_time, 0.02)
86
- assert_in_delta(0, method.self_time, 0.02)
87
- assert_in_delta(0, method.wait_time, 0.02)
88
- assert_in_delta(7, method.children_time, 0.02)
89
- assert_equal(0, method.called)
90
- assert_equal(0, method.parents.length)
91
- assert_equal(1, method.children.length)
92
-
93
- method = methods[1]
94
- assert_equal('Object#method3', method.full_name)
95
- assert_in_delta(7, method.total_time, 0.02)
96
- assert_in_delta(0, method.self_time, 0.02)
97
- assert_in_delta(0, method.wait_time, 0.02)
98
- assert_in_delta(7, method.children_time, 0.02)
99
- assert_equal(1, method.called)
100
- assert_equal(1, method.parents.length)
101
- assert_equal(3, method.children.length)
102
-
103
- method = methods[2]
104
- assert_equal('Kernel#sleep', method.full_name)
105
- assert_in_delta(7, method.total_time, 0.02)
106
- assert_in_delta(7, method.self_time, 0.02)
107
- assert_in_delta(0, method.wait_time, 0.02)
108
- assert_in_delta(0, method.children_time, 0.02)
109
- assert_equal(4, method.called)
110
- assert_equal(3, method.parents.length)
111
- assert_equal(0, method.children.length)
112
-
113
- method = methods[3]
114
- assert_equal('Object#method2', method.full_name)
115
- assert_in_delta(3, method.total_time, 0.02)
116
- assert_in_delta(0, method.self_time, 0.02)
117
- assert_in_delta(0, method.wait_time, 0.02)
118
- assert_in_delta(3, method.children_time, 0.02)
119
- assert_equal(1, method.called)
120
- assert_equal(1, method.parents.length)
121
- assert_equal(2, method.children.length)
122
-
123
- method = methods[4]
124
- assert_equal('Object#method1', method.full_name)
125
- assert_in_delta(2, method.total_time, 0.02)
126
- assert_in_delta(0, method.self_time, 0.02)
127
- assert_in_delta(0, method.wait_time, 0.02)
128
- assert_in_delta(2, method.children_time, 0.02)
129
- assert_equal(2, method.called)
130
- assert_equal(2, method.parents.length)
131
- assert_equal(1, method.children.length)
132
- end
133
- end