ruby-prof 0.15.9 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +27 -1
- data/README.rdoc +83 -31
- data/bin/ruby-prof +4 -4
- data/doc/LICENSE.html +1 -1
- data/doc/README_rdoc.html +92 -33
- data/doc/Rack.html +1 -1
- data/doc/Rack/RubyProf.html +17 -14
- data/doc/RubyProf.html +30 -29
- data/doc/RubyProf/AbstractPrinter.html +1 -1
- data/doc/RubyProf/AggregateCallInfo.html +1 -1
- data/doc/RubyProf/CallInfo.html +1 -1
- data/doc/RubyProf/CallInfoPrinter.html +1 -1
- data/doc/RubyProf/CallInfoVisitor.html +1 -1
- data/doc/RubyProf/CallStackPrinter.html +1 -1
- data/doc/RubyProf/CallTreePrinter.html +349 -67
- data/doc/RubyProf/Cmd.html +5 -5
- data/doc/RubyProf/DotPrinter.html +2 -2
- data/doc/RubyProf/FlatPrinter.html +1 -1
- data/doc/RubyProf/FlatPrinterWithLineNumbers.html +1 -1
- data/doc/RubyProf/GraphHtmlPrinter.html +1 -1
- data/doc/RubyProf/GraphPrinter.html +1 -1
- data/doc/RubyProf/MethodInfo.html +2 -2
- data/doc/RubyProf/MultiPrinter.html +11 -9
- data/doc/RubyProf/Profile.html +94 -44
- data/doc/RubyProf/ProfileTask.html +1 -1
- data/doc/RubyProf/Thread.html +43 -1
- data/doc/created.rid +16 -16
- data/doc/examples/flat_txt.html +1 -1
- data/doc/examples/graph_html.html +1 -1
- data/doc/examples/graph_txt.html +3 -3
- data/doc/index.html +85 -30
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search_index.js +1 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +2 -2
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +117 -68
- data/examples/cachegrind.out.1 +114 -0
- data/examples/cachegrind.out.1.32313213 +114 -0
- data/examples/graph.txt +1 -1
- data/ext/ruby_prof/extconf.rb +6 -2
- data/ext/ruby_prof/rp_measure_cpu_time.c +29 -31
- data/ext/ruby_prof/rp_method.c +1 -1
- data/ext/ruby_prof/rp_thread.c +57 -52
- data/ext/ruby_prof/ruby_prof.c +122 -66
- data/ext/ruby_prof/ruby_prof.h +2 -0
- data/lib/ruby-prof.rb +14 -13
- data/lib/ruby-prof/assets/call_stack_printer.js.html +1 -1
- data/lib/ruby-prof/compatibility.rb +9 -8
- data/lib/ruby-prof/method_info.rb +1 -1
- data/lib/ruby-prof/printers/call_tree_printer.rb +88 -50
- data/lib/ruby-prof/printers/dot_printer.rb +1 -1
- data/lib/ruby-prof/printers/multi_printer.rb +6 -4
- data/lib/ruby-prof/profile.rb +0 -1
- data/lib/ruby-prof/rack.rb +53 -16
- data/lib/ruby-prof/thread.rb +11 -0
- data/lib/ruby-prof/version.rb +1 -1
- data/test/exclude_threads_test.rb +2 -3
- data/test/fiber_test.rb +21 -7
- data/test/measure_cpu_time_test.rb +84 -24
- data/test/multi_printer_test.rb +5 -4
- data/test/pause_resume_test.rb +7 -7
- data/test/printers_test.rb +6 -4
- data/test/rack_test.rb +26 -1
- data/test/test_helper.rb +28 -3
- data/test/thread_test.rb +1 -0
- metadata +5 -3
data/test/multi_printer_test.rb
CHANGED
@@ -63,6 +63,7 @@ class MultiPrinterTest < TestCase
|
|
63
63
|
end
|
64
64
|
|
65
65
|
private
|
66
|
+
|
66
67
|
def print(result)
|
67
68
|
test = caller.first =~ /in `(.*)'/ ? $1 : "test"
|
68
69
|
path = RubyProf.tmpdir
|
@@ -73,10 +74,10 @@ class MultiPrinterTest < TestCase
|
|
73
74
|
if RUBY_PLATFORM =~ /darwin/ && ENV['SHOW_RUBY_PROF_PRINTER_OUTPUT']=="1"
|
74
75
|
system("open '#{printer.stack_profile}'")
|
75
76
|
end
|
76
|
-
if GC.respond_to?(:dump_file_and_line_info)
|
77
|
-
|
78
|
-
|
79
|
-
end
|
77
|
+
# if GC.respond_to?(:dump_file_and_line_info)
|
78
|
+
# GC.start
|
79
|
+
# GC.dump_file_and_line_info("heap.dump")
|
80
|
+
# end
|
80
81
|
[File.read(printer.stack_profile), File.read(printer.graph_profile)]
|
81
82
|
end
|
82
83
|
end
|
data/test/pause_resume_test.rb
CHANGED
@@ -58,7 +58,7 @@ class PauseResumeTest < TestCase
|
|
58
58
|
|
59
59
|
# pause/resume in the same frame
|
60
60
|
def test_pause_resume_1
|
61
|
-
profile = RubyProf::Profile.new
|
61
|
+
profile = RubyProf::Profile.new
|
62
62
|
|
63
63
|
profile.start
|
64
64
|
method_1a
|
@@ -78,7 +78,7 @@ class PauseResumeTest < TestCase
|
|
78
78
|
|
79
79
|
# pause in parent frame, resume in child
|
80
80
|
def test_pause_resume_2
|
81
|
-
profile = RubyProf::Profile.new
|
81
|
+
profile = RubyProf::Profile.new
|
82
82
|
|
83
83
|
profile.start
|
84
84
|
method_2a
|
@@ -95,7 +95,7 @@ class PauseResumeTest < TestCase
|
|
95
95
|
|
96
96
|
# pause in child frame, resume in parent
|
97
97
|
def test_pause_resume_3
|
98
|
-
profile = RubyProf::Profile.new
|
98
|
+
profile = RubyProf::Profile.new
|
99
99
|
|
100
100
|
profile.start
|
101
101
|
method_3a(profile)
|
@@ -111,7 +111,7 @@ class PauseResumeTest < TestCase
|
|
111
111
|
def method_3b; sleep 0.4 end
|
112
112
|
|
113
113
|
def test_pause_seq
|
114
|
-
profile = RubyProf::Profile.new
|
114
|
+
profile = RubyProf::Profile.new
|
115
115
|
profile.start ; assert !profile.paused?
|
116
116
|
profile.pause ; assert profile.paused?
|
117
117
|
profile.resume; assert !profile.paused?
|
@@ -123,7 +123,7 @@ class PauseResumeTest < TestCase
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def test_pause_block
|
126
|
-
profile = RubyProf::Profile.new
|
126
|
+
profile = RubyProf::Profile.new
|
127
127
|
profile.start
|
128
128
|
profile.pause
|
129
129
|
assert profile.paused?
|
@@ -142,7 +142,7 @@ class PauseResumeTest < TestCase
|
|
142
142
|
end
|
143
143
|
|
144
144
|
def test_pause_block_with_error
|
145
|
-
profile = RubyProf::Profile.new
|
145
|
+
profile = RubyProf::Profile.new
|
146
146
|
profile.start
|
147
147
|
profile.pause
|
148
148
|
assert profile.paused?
|
@@ -158,7 +158,7 @@ class PauseResumeTest < TestCase
|
|
158
158
|
end
|
159
159
|
|
160
160
|
def test_resume_when_not_paused
|
161
|
-
profile = RubyProf::Profile.new
|
161
|
+
profile = RubyProf::Profile.new
|
162
162
|
profile.start ; assert !profile.paused?
|
163
163
|
profile.resume; assert !profile.paused?
|
164
164
|
profile.stop ; assert !profile.paused?
|
data/test/printers_test.rb
CHANGED
@@ -23,7 +23,7 @@ class PrintersTest < TestCase
|
|
23
23
|
printer.print(output)
|
24
24
|
|
25
25
|
printer = RubyProf::CallTreePrinter.new(@result)
|
26
|
-
printer.print(
|
26
|
+
printer.print()
|
27
27
|
|
28
28
|
printer = RubyProf::FlatPrinter.new(@result)
|
29
29
|
printer.print(output)
|
@@ -56,7 +56,7 @@ class PrintersTest < TestCase
|
|
56
56
|
|
57
57
|
printer = RubyProf::MultiPrinter.new(@result)
|
58
58
|
printer.print(:path => "#{output_dir}", :profile => "multi", :application => "primes")
|
59
|
-
for file in ['graph.dot', 'multi.flat.txt', 'multi.graph.html',
|
59
|
+
for file in ['graph.dot', 'multi.flat.txt', 'multi.graph.html', "multi.callgrind.out.#{$$}", 'multi.stack.html', 'stack.html']
|
60
60
|
existant_file = output_dir + '/' + file
|
61
61
|
assert File.size(existant_file) > 0
|
62
62
|
end
|
@@ -115,9 +115,11 @@ class PrintersTest < TestCase
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def test_call_tree_string
|
118
|
-
output = ''
|
119
118
|
printer = RubyProf::CallTreePrinter.new(@result)
|
120
|
-
printer.print(
|
119
|
+
printer.print(:profile => "lolcat", :path => RubyProf.tmpdir)
|
120
|
+
main_output_file_name = File.join(RubyProf.tmpdir, "lolcat.callgrind.out.#{$$}")
|
121
|
+
assert(File.exist?(main_output_file_name))
|
122
|
+
output = File.read(main_output_file_name)
|
121
123
|
assert_match(/fn=Object#find_primes/i, output)
|
122
124
|
assert_match(/events: wall_time/i, output)
|
123
125
|
refute_match(/d\d\d\d\d\d/, output) # old bug looked [in error] like Object::run_primes(d5833116)
|
data/test/rack_test.rb
CHANGED
@@ -11,9 +11,15 @@ end
|
|
11
11
|
module Rack
|
12
12
|
class Request
|
13
13
|
def initialize(env)
|
14
|
+
if env == :fake_env
|
15
|
+
@env = {}
|
16
|
+
else
|
17
|
+
@env = env
|
18
|
+
end
|
14
19
|
end
|
20
|
+
|
15
21
|
def path
|
16
|
-
'/path/to/resource.json'
|
22
|
+
@env[:path] || '/path/to/resource.json'
|
17
23
|
end
|
18
24
|
end
|
19
25
|
end
|
@@ -54,6 +60,25 @@ class RackTest < TestCase
|
|
54
60
|
end
|
55
61
|
end
|
56
62
|
|
63
|
+
def test_only_paths
|
64
|
+
path = Dir.mktmpdir
|
65
|
+
|
66
|
+
adapter = Rack::RubyProf.new(FakeRackApp.new, :path => path, :only_paths => [%r{\.json$}])
|
67
|
+
|
68
|
+
adapter.call({path: '/path/to/resource.json'})
|
69
|
+
|
70
|
+
%w(flat.txt graph.txt graph.html call_stack.html).each do |base_name|
|
71
|
+
file_path = ::File.join(path, "path-to-resource.json-#{base_name}")
|
72
|
+
assert(File.exist?(file_path))
|
73
|
+
end
|
74
|
+
|
75
|
+
adapter.call({path: '/path/to/resource.html'})
|
76
|
+
%w(flat.txt graph.txt graph.html call_stack.html).each do |base_name|
|
77
|
+
file_path = ::File.join(path, "path-to-resource.html-#{base_name}")
|
78
|
+
assert(!File.exist?(file_path))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
57
82
|
def test_allows_lazy_filename_setting
|
58
83
|
path = Dir.mktmpdir
|
59
84
|
|
data/test/test_helper.rb
CHANGED
@@ -28,9 +28,22 @@ require 'ruby-prof'
|
|
28
28
|
require 'minitest/autorun'
|
29
29
|
|
30
30
|
class TestCase < Minitest::Test
|
31
|
+
# I know this sucks, but ...
|
31
32
|
def assert_nothing_raised(*)
|
32
33
|
yield
|
33
34
|
end
|
35
|
+
|
36
|
+
def before_setup
|
37
|
+
# make sure to exclude all threads except the one running the test
|
38
|
+
# minitest allocates a thread pool and they would otherwise show
|
39
|
+
# up in the profile data, breaking tests randomly
|
40
|
+
RubyProf.exclude_threads = Thread.list.select{|t| t != Thread.current}
|
41
|
+
end
|
42
|
+
|
43
|
+
def after_teardown
|
44
|
+
# reset exclude threads after testing
|
45
|
+
RubyProf.exclude_threads = nil
|
46
|
+
end
|
34
47
|
end
|
35
48
|
|
36
49
|
require File.expand_path('../prime', __FILE__)
|
@@ -85,22 +98,34 @@ module RubyProf
|
|
85
98
|
end
|
86
99
|
|
87
100
|
class C7
|
88
|
-
def self.
|
101
|
+
def self.busy_wait
|
89
102
|
t = Time.now.to_f
|
90
103
|
while Time.now.to_f - t < 0.1; end
|
91
104
|
end
|
92
105
|
|
93
|
-
def
|
106
|
+
def self.sleep_wait
|
107
|
+
sleep 0.1
|
108
|
+
end
|
109
|
+
|
110
|
+
def busy_wait
|
94
111
|
t = Time.now.to_f
|
95
112
|
while Time.now.to_f - t < 0.2; end
|
96
113
|
end
|
114
|
+
|
115
|
+
def sleep_wait
|
116
|
+
sleep 0.2
|
117
|
+
end
|
97
118
|
end
|
98
119
|
|
99
120
|
module M7
|
100
|
-
def
|
121
|
+
def busy_wait
|
101
122
|
t = Time.now.to_f
|
102
123
|
while Time.now.to_f - t < 0.3; end
|
103
124
|
end
|
125
|
+
|
126
|
+
def sleep_wait
|
127
|
+
sleep 0.3
|
128
|
+
end
|
104
129
|
end
|
105
130
|
|
106
131
|
class C8
|
data/test/thread_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-prof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shugo Maeda, Charlie Savage, Roger Pack, Stefan Kaes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -144,6 +144,8 @@ files:
|
|
144
144
|
- doc/js/searcher.js
|
145
145
|
- doc/js/searcher.js.gz
|
146
146
|
- doc/table_of_contents.html
|
147
|
+
- examples/cachegrind.out.1
|
148
|
+
- examples/cachegrind.out.1.32313213
|
147
149
|
- examples/flat.txt
|
148
150
|
- examples/graph.dot
|
149
151
|
- examples/graph.html
|
@@ -261,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
263
|
version: '0'
|
262
264
|
requirements: []
|
263
265
|
rubyforge_project:
|
264
|
-
rubygems_version: 2.4
|
266
|
+
rubygems_version: 2.6.4
|
265
267
|
signing_key:
|
266
268
|
specification_version: 4
|
267
269
|
summary: Fast Ruby profiler
|