ruby-prof 0.12.1 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +5 -1
- data/Rakefile +25 -7
- data/bin/ruby-prof +2 -2
- data/doc/LICENSE.html +155 -0
- data/doc/README_rdoc.html +640 -0
- data/doc/Rack.html +167 -0
- data/doc/Rack/RubyProf.html +319 -0
- data/doc/RubyProf.html +999 -0
- data/doc/RubyProf/AbstractPrinter.html +580 -0
- data/doc/RubyProf/AggregateCallInfo.html +570 -0
- data/doc/RubyProf/CallInfo.html +512 -0
- data/doc/RubyProf/CallInfoPrinter.html +190 -0
- data/doc/RubyProf/CallInfoVisitor.html +332 -0
- data/doc/RubyProf/CallStackPrinter.html +1597 -0
- data/doc/RubyProf/CallTreePrinter.html +413 -0
- data/doc/RubyProf/Cmd.html +669 -0
- data/doc/RubyProf/DotPrinter.html +312 -0
- data/doc/RubyProf/FlatPrinter.html +229 -0
- data/doc/RubyProf/FlatPrinterWithLineNumbers.html +267 -0
- data/doc/RubyProf/GraphHtmlPrinter.html +622 -0
- data/doc/RubyProf/GraphPrinter.html +209 -0
- data/doc/RubyProf/MethodInfo.html +713 -0
- data/doc/RubyProf/MultiPrinter.html +407 -0
- data/doc/RubyProf/Profile.html +821 -0
- data/doc/RubyProf/ProfileTask.html +532 -0
- data/doc/RubyProf/Test.html +578 -0
- data/doc/RubyProf/Thread.html +262 -0
- data/doc/created.rid +31 -0
- data/doc/examples/flat_txt.html +191 -0
- data/doc/examples/graph_txt.html +305 -0
- data/doc/images/add.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +639 -0
- data/doc/js/darkfish.js +153 -0
- data/doc/js/jquery.js +18 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search.js +94 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searcher.js +228 -0
- data/doc/rdoc.css +543 -0
- data/doc/table_of_contents.html +462 -0
- data/examples/empty.png +0 -0
- data/examples/minus.png +0 -0
- data/examples/plus.png +0 -0
- data/ext/ruby_prof/extconf.rb +5 -1
- data/ext/ruby_prof/rp_call_info.c +1 -1
- data/ext/ruby_prof/rp_measure_gc_time.c +6 -10
- data/ext/ruby_prof/rp_measure_memory.c +0 -1
- data/ext/ruby_prof/rp_stack.c +0 -5
- data/ext/ruby_prof/vc/ruby_prof_18.vcxproj +0 -2
- data/ext/ruby_prof/vc/ruby_prof_19.vcxproj +1 -3
- data/ext/ruby_prof/vc/ruby_prof_20.vcxproj +1 -3
- data/ext/ruby_prof/version.h +2 -2
- data/lib/ruby-prof/compatibility.rb +8 -3
- data/lib/ruby-prof/images/empty.png +0 -0
- data/lib/ruby-prof/images/minus.png +0 -0
- data/lib/ruby-prof/images/plus.png +0 -0
- data/lib/ruby-prof/task.rb +0 -0
- data/ruby-prof.gemspec +2 -1
- data/test/aggregate_test.rb +0 -0
- data/test/basic_test.rb +0 -0
- data/test/duplicate_names_test.rb +0 -0
- data/test/dynamic_method_test.rb +8 -1
- data/test/enumerable_test.rb +0 -0
- data/test/exceptions_test.rb +0 -0
- data/test/exclude_threads_test.rb +0 -0
- data/test/exec_test.rb +0 -0
- data/test/line_number_test.rb +0 -0
- data/test/measure_gc_runs_test.rb +4 -1
- data/test/measure_gc_time_test.rb +10 -3
- data/test/measure_memory_test.rb +3 -8
- data/test/measure_process_time_test.rb +10 -4
- data/test/method_elimination_test.rb +1 -2
- data/test/module_test.rb +0 -0
- data/test/multi_printer_test.rb +5 -6
- data/test/no_method_class_test.rb +0 -0
- data/test/pause_resume_test.rb +6 -8
- data/test/printers_test.rb +0 -0
- data/test/recursive_test.rb +0 -0
- data/test/singleton_test.rb +0 -0
- data/test/stack_printer_test.rb +8 -5
- data/test/stack_test.rb +0 -0
- data/test/start_stop_test.rb +0 -0
- data/test/test_helper.rb +16 -4
- data/test/thread_test.rb +0 -0
- data/test/unique_call_path_test.rb +0 -0
- metadata +90 -17
data/examples/empty.png
CHANGED
File without changes
|
data/examples/minus.png
CHANGED
File without changes
|
data/examples/plus.png
CHANGED
File without changes
|
data/ext/ruby_prof/extconf.rb
CHANGED
@@ -34,6 +34,10 @@ def add_define(name, value = nil)
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
# if have_func("rb_gc_enable_stats")
|
38
|
+
# add_define("TOGGLE_GC_STATS", 1)
|
39
|
+
# end
|
40
|
+
|
37
41
|
require 'rubygems'
|
38
42
|
unless Gem.win_platform? || RUBY_PLATFORM =~ /darwin/
|
39
43
|
$LDFLAGS += " -lrt" # for clock_gettime
|
@@ -50,4 +54,4 @@ if RUBY_VERSION > "1.9"
|
|
50
54
|
add_define("THREADS_INHERIT_EVENT_FLAGS", (threads.size == 2) ? "1" : "0")
|
51
55
|
end
|
52
56
|
|
53
|
-
create_makefile("ruby_prof")
|
57
|
+
create_makefile("ruby_prof")
|
@@ -17,16 +17,16 @@ measure_gc_time()
|
|
17
17
|
{
|
18
18
|
#if defined(HAVE_RB_GC_TIME)
|
19
19
|
#define MEASURE_GC_TIME_ENABLED Qtrue
|
20
|
-
const
|
20
|
+
const double conversion = 1000000.0;
|
21
21
|
#if HAVE_LONG_LONG
|
22
|
-
return NUM2LL(rb_gc_time() / conversion
|
22
|
+
return NUM2LL(rb_gc_time()) / conversion;
|
23
23
|
#else
|
24
|
-
return NUM2LONG(rb_gc_time() / conversion
|
24
|
+
return NUM2LONG(rb_gc_time()) / conversion;
|
25
25
|
#endif
|
26
26
|
|
27
27
|
#else
|
28
28
|
#define MEASURE_GC_TIME_ENABLED Qfalse
|
29
|
-
return 0;
|
29
|
+
return 0.0;
|
30
30
|
#endif
|
31
31
|
}
|
32
32
|
|
@@ -40,15 +40,11 @@ prof_measurer_t* prof_measurer_gc_time()
|
|
40
40
|
/* call-seq:
|
41
41
|
measure -> float
|
42
42
|
|
43
|
-
Returns the
|
43
|
+
Returns the time spent performing GC.*/
|
44
44
|
static VALUE
|
45
45
|
prof_measure_gc_time(VALUE self)
|
46
46
|
{
|
47
|
-
|
48
|
-
return ULL2NUM(measure_gc_time());
|
49
|
-
#else
|
50
|
-
return ULONG2NUM(measure_gc_time());
|
51
|
-
#endif
|
47
|
+
return rb_float_new(measure_gc_time());
|
52
48
|
}
|
53
49
|
|
54
50
|
void rp_init_measure_gc_time()
|
data/ext/ruby_prof/rp_stack.c
CHANGED
@@ -84,11 +84,6 @@ prof_stack_pop(prof_stack_t *stack, double measurement)
|
|
84
84
|
|
85
85
|
double total_time;
|
86
86
|
double self_time;
|
87
|
-
#ifdef _MSC_VER
|
88
|
-
BOOL frame_paused;
|
89
|
-
#else
|
90
|
-
_Bool frame_paused;
|
91
|
-
#endif
|
92
87
|
|
93
88
|
/* Frame can be null. This can happen if RubProf.start is called from
|
94
89
|
a method that exits. And it can happen if an exception is raised
|
@@ -44,14 +44,12 @@
|
|
44
44
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
45
45
|
<UseDebugLibraries>true</UseDebugLibraries>
|
46
46
|
<CharacterSet>Unicode</CharacterSet>
|
47
|
-
<PlatformToolset>v110</PlatformToolset>
|
48
47
|
</PropertyGroup>
|
49
48
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
50
49
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
51
50
|
<UseDebugLibraries>false</UseDebugLibraries>
|
52
51
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
53
52
|
<CharacterSet>Unicode</CharacterSet>
|
54
|
-
<PlatformToolset>v110</PlatformToolset>
|
55
53
|
</PropertyGroup>
|
56
54
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
57
55
|
<ImportGroup Label="ExtensionSettings">
|
@@ -20,14 +20,12 @@
|
|
20
20
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
21
21
|
<UseDebugLibraries>true</UseDebugLibraries>
|
22
22
|
<CharacterSet>Unicode</CharacterSet>
|
23
|
-
<PlatformToolset>v110</PlatformToolset>
|
24
23
|
</PropertyGroup>
|
25
24
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
26
25
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
27
26
|
<UseDebugLibraries>false</UseDebugLibraries>
|
28
27
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
29
28
|
<CharacterSet>Unicode</CharacterSet>
|
30
|
-
<PlatformToolset>v110</PlatformToolset>
|
31
29
|
</PropertyGroup>
|
32
30
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
33
31
|
<ImportGroup Label="ExtensionSettings">
|
@@ -55,7 +53,7 @@
|
|
55
53
|
<WarningLevel>Level3</WarningLevel>
|
56
54
|
<Optimization>Disabled</Optimization>
|
57
55
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;RUBY_PROF_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
58
|
-
<AdditionalIncludeDirectories>C:\MinGW\local\ruby193vc\include\ruby-1.9.1;C:\MinGW\local\ruby193vc\include\ruby-1.9.1\i386-
|
56
|
+
<AdditionalIncludeDirectories>C:\MinGW\local\ruby193vc\include\ruby-1.9.1;C:\MinGW\local\ruby193vc\include\ruby-1.9.1\i386-mswin32_100;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
59
57
|
</ClCompile>
|
60
58
|
<Link>
|
61
59
|
<SubSystem>Windows</SubSystem>
|
@@ -20,14 +20,12 @@
|
|
20
20
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
21
21
|
<UseDebugLibraries>true</UseDebugLibraries>
|
22
22
|
<CharacterSet>Unicode</CharacterSet>
|
23
|
-
<PlatformToolset>v110</PlatformToolset>
|
24
23
|
</PropertyGroup>
|
25
24
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
26
25
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
27
26
|
<UseDebugLibraries>false</UseDebugLibraries>
|
28
27
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
29
28
|
<CharacterSet>Unicode</CharacterSet>
|
30
|
-
<PlatformToolset>v110</PlatformToolset>
|
31
29
|
</PropertyGroup>
|
32
30
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
33
31
|
<ImportGroup Label="ExtensionSettings">
|
@@ -55,7 +53,7 @@
|
|
55
53
|
<WarningLevel>Level3</WarningLevel>
|
56
54
|
<Optimization>Disabled</Optimization>
|
57
55
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;RUBY_PROF_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
58
|
-
<AdditionalIncludeDirectories>C:\MinGW\local\ruby200vc\include\ruby-2.0.0;C:\MinGW\local\ruby200vc\include\ruby-2.0.0\i386-
|
56
|
+
<AdditionalIncludeDirectories>C:\MinGW\local\ruby200vc\include\ruby-2.0.0;C:\MinGW\local\ruby200vc\include\ruby-2.0.0\i386-mswin32_100;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
59
57
|
</ClCompile>
|
60
58
|
<Link>
|
61
59
|
<SubSystem>Windows</SubSystem>
|
data/ext/ruby_prof/version.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
|
2
2
|
Please see the LICENSE file for copyright and distribution information */
|
3
3
|
|
4
|
-
#define RUBY_PROF_VERSION "0.12.
|
4
|
+
#define RUBY_PROF_VERSION "0.12.2" // as a string, for easy parsing from rake files
|
5
5
|
#define RUBY_PROF_VERSION_MAJ 0
|
6
6
|
#define RUBY_PROF_VERSION_MIN 12
|
7
|
-
#define RUBY_PROF_VERSION_MIC
|
7
|
+
#define RUBY_PROF_VERSION_MIC 2
|
@@ -152,13 +152,18 @@ private
|
|
152
152
|
|
153
153
|
# for GC.allocated_size to work GC statistics should be enabled
|
154
154
|
def self.enable_gc_stats_if_needed
|
155
|
-
if
|
155
|
+
if measure_mode_requires_gc_stats_enabled?
|
156
156
|
@gc_stat_was_enabled = GC.enable_stats
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
160
|
def self.disable_gc_stats_if_needed(was_enabled=nil)
|
161
161
|
was_enabled ||= defined?(@gc_stat_was_enabled) && @gc_stat_was_enabled
|
162
|
-
GC.disable_stats if
|
162
|
+
GC.disable_stats if measure_mode_requires_gc_stats_enabled? && !was_enabled
|
163
163
|
end
|
164
|
-
|
164
|
+
|
165
|
+
def self.measure_mode_requires_gc_stats_enabled?
|
166
|
+
GC.respond_to?(:enable_stats) &&
|
167
|
+
[RubyProf::MEMORY, RubyProf::GC_TIME, RubyProf::GC_RUNS].include?(measure_mode)
|
168
|
+
end
|
169
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
data/lib/ruby-prof/task.rb
CHANGED
File without changes
|
data/ruby-prof.gemspec
CHANGED
data/test/aggregate_test.rb
CHANGED
File without changes
|
data/test/basic_test.rb
CHANGED
File without changes
|
File without changes
|
data/test/dynamic_method_test.rb
CHANGED
@@ -17,7 +17,7 @@ class DynamicMethodTest < Test::Unit::TestCase
|
|
17
17
|
# Methods called
|
18
18
|
# Kernel#sleep
|
19
19
|
# <Class::BasicObject>#allocate
|
20
|
-
# #{RubyProf.parent_object}
|
20
|
+
# #{RubyProf.parent_object}#inizialize
|
21
21
|
# RubyProf::C1#hello
|
22
22
|
# Class#new
|
23
23
|
# Integer#times
|
@@ -52,6 +52,13 @@ class DynamicMethodTest < Test::Unit::TestCase
|
|
52
52
|
assert_in_delta(0.0, methods[4].wait_time, 0.01)
|
53
53
|
assert_in_delta(0.0, methods[4].self_time, 0.01)
|
54
54
|
|
55
|
+
# the timing difference between #initialize and #allocate is so small
|
56
|
+
# that we cannot rely on #initialize appearing first.
|
57
|
+
# so switch them, if necessary
|
58
|
+
if methods[5].full_name =~ /#allocate/
|
59
|
+
methods[5], methods[6] = methods[6], methods[5]
|
60
|
+
end
|
61
|
+
|
55
62
|
assert_equal("#{RubyProf.parent_object}#initialize", methods[5].full_name)
|
56
63
|
assert_in_delta(0.0, methods[5].total_time, 0.01)
|
57
64
|
assert_in_delta(0.0, methods[5].wait_time, 0.01)
|
data/test/enumerable_test.rb
CHANGED
File without changes
|
data/test/exceptions_test.rb
CHANGED
File without changes
|
File without changes
|
data/test/exec_test.rb
CHANGED
File without changes
|
data/test/line_number_test.rb
CHANGED
File without changes
|
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
require File.expand_path('../test_helper', __FILE__)
|
5
5
|
|
6
|
-
class
|
6
|
+
class MeasureGCRunsTest < Test::Unit::TestCase
|
7
|
+
include MemoryTestHelper
|
8
|
+
|
7
9
|
def test_gc_runs_mode
|
8
10
|
RubyProf::measure_mode = RubyProf::GC_RUNS
|
9
11
|
assert_equal(RubyProf::GC_RUNS, RubyProf::measure_mode)
|
@@ -18,6 +20,7 @@ class MeasuremeGCRunsTest < Test::Unit::TestCase
|
|
18
20
|
t = RubyProf.measure_gc_runs
|
19
21
|
assert_kind_of Integer, t
|
20
22
|
|
23
|
+
GC.enable_stats
|
21
24
|
GC.start
|
22
25
|
|
23
26
|
u = RubyProf.measure_gc_runs
|
@@ -4,6 +4,8 @@
|
|
4
4
|
require File.expand_path('../test_helper', __FILE__)
|
5
5
|
|
6
6
|
class MeasureGCTimeTest < Test::Unit::TestCase
|
7
|
+
include MemoryTestHelper
|
8
|
+
|
7
9
|
def test_gc_time_mode
|
8
10
|
RubyProf::measure_mode = RubyProf::GC_TIME
|
9
11
|
assert_equal(RubyProf::GC_TIME, RubyProf::measure_mode)
|
@@ -15,15 +17,20 @@ class MeasureGCTimeTest < Test::Unit::TestCase
|
|
15
17
|
|
16
18
|
if RubyProf::GC_TIME_ENABLED
|
17
19
|
def test_gc_time
|
20
|
+
RubyProf::measure_mode = RubyProf::GC_TIME
|
21
|
+
RubyProf.enable_gc_stats_if_needed
|
22
|
+
|
18
23
|
t = RubyProf.measure_gc_time
|
19
|
-
assert_kind_of
|
24
|
+
assert_kind_of Float, t
|
20
25
|
|
21
26
|
GC.start
|
22
27
|
|
23
28
|
u = RubyProf.measure_gc_time
|
24
29
|
assert u > t, [t, u].inspect
|
25
|
-
|
30
|
+
|
26
31
|
memory_test_helper
|
32
|
+
ensure
|
33
|
+
RubyProf.disable_gc_stats_if_needed
|
27
34
|
end
|
28
35
|
end
|
29
|
-
end
|
36
|
+
end
|
data/test/measure_memory_test.rb
CHANGED
@@ -4,12 +4,7 @@
|
|
4
4
|
require File.expand_path('../test_helper', __FILE__)
|
5
5
|
|
6
6
|
class MeasureMemoryTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
result = RubyProf.profile {Array.new}
|
9
|
-
total = result.threads.values.first.inject(0) { |sum, m| sum + m.total_time }
|
10
|
-
assert(total < 1_000_000, 'Total should not have subtract overflow error')
|
11
|
-
total
|
12
|
-
end
|
7
|
+
include MemoryTestHelper
|
13
8
|
|
14
9
|
def test_memory_mode
|
15
10
|
RubyProf::measure_mode = RubyProf::MEMORY
|
@@ -23,10 +18,10 @@ class MeasureMemoryTest < Test::Unit::TestCase
|
|
23
18
|
if RubyProf::MEMORY_ENABLED
|
24
19
|
def test_memory
|
25
20
|
t = RubyProf.measure_memory
|
26
|
-
assert_kind_of
|
21
|
+
assert_kind_of Float, t
|
27
22
|
|
28
23
|
u = RubyProf.measure_memory
|
29
|
-
assert(u
|
24
|
+
assert(u > t, [t, u].inspect)
|
30
25
|
RubyProf::measure_mode = RubyProf::MEMORY
|
31
26
|
total = memory_test_helper
|
32
27
|
assert(total > 0, 'Should measure more than zero kilobytes of memory usage')
|
@@ -10,7 +10,6 @@ class MeasureProcessTimeTest < Test::Unit::TestCase
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_mode
|
13
|
-
RubyProf::measure_mode = RubyProf::PROCESS_TIME
|
14
13
|
assert_equal(RubyProf::PROCESS_TIME, RubyProf::measure_mode)
|
15
14
|
end
|
16
15
|
|
@@ -28,11 +27,18 @@ class MeasureProcessTimeTest < Test::Unit::TestCase
|
|
28
27
|
total_time = (finish.utime - start.utime) + (finish.stime - start.stime)
|
29
28
|
|
30
29
|
thread = result.threads.first
|
31
|
-
assert_in_delta(total_time, thread.total_time, 0.
|
30
|
+
assert_in_delta(total_time, thread.total_time, 0.03)
|
32
31
|
|
33
32
|
methods = result.threads.first.methods.sort.reverse
|
34
33
|
|
35
|
-
|
34
|
+
if RUBY_VERSION =~ /^1\.8/
|
35
|
+
methods.reject!{|m| m.full_name =~ /^Fixnum/ || m.full_name == 'Object#find_largest'}
|
36
|
+
end
|
37
|
+
if RUBY_VERSION =~ /^(1\.9\.2|2\.0)/
|
38
|
+
assert_equal 15, methods.length
|
39
|
+
else
|
40
|
+
assert_equal 16, methods.length
|
41
|
+
end
|
36
42
|
|
37
43
|
# Check times
|
38
44
|
assert_equal("MeasureProcessTimeTest#test_primes", methods[0].full_name)
|
@@ -53,4 +59,4 @@ class MeasureProcessTimeTest < Test::Unit::TestCase
|
|
53
59
|
assert_equal("Array#each_index", methods[7].full_name)
|
54
60
|
assert_equal("Kernel#rand", methods[8].full_name)
|
55
61
|
end
|
56
|
-
end
|
62
|
+
end
|
@@ -2,7 +2,6 @@
|
|
2
2
|
# encoding: UTF-8
|
3
3
|
|
4
4
|
require File.expand_path('../test_helper', __FILE__)
|
5
|
-
require 'tmpdir'
|
6
5
|
|
7
6
|
# Test data
|
8
7
|
# A
|
@@ -35,7 +34,7 @@ class MethodEliminationTest < Test::Unit::TestCase
|
|
35
34
|
result = RubyProf.profile do
|
36
35
|
1000.times { 1+1 }
|
37
36
|
end
|
38
|
-
method_infos = result.threads.first.methods
|
37
|
+
method_infos = result.threads.first.methods.sort.reverse
|
39
38
|
assert(m1 = method_infos[0])
|
40
39
|
assert(c1 = m1.call_infos.first)
|
41
40
|
assert_nil(c1.parent)
|
data/test/module_test.rb
CHANGED
File without changes
|
data/test/multi_printer_test.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
# encoding: UTF-8
|
3
3
|
|
4
4
|
require File.expand_path('../test_helper', __FILE__)
|
5
|
-
require 'tmpdir'
|
6
5
|
|
7
6
|
# Test data
|
8
7
|
# A
|
@@ -50,20 +49,20 @@ class MultiPrinterTest < Test::Unit::TestCase
|
|
50
49
|
\s*</tr>
|
51
50
|
\s*
|
52
51
|
\s*<tr>
|
53
|
-
\s*<td><a href="
|
52
|
+
\s*<td><a href="#-?\d+">-?\d+</a></td>
|
54
53
|
\s*<td>([\.0-9]+)</td>
|
55
54
|
\s*</tr>
|
56
55
|
\s*
|
57
56
|
\s*</table>')
|
58
|
-
|
57
|
+
assert_match(re, graph)
|
59
58
|
display_time = $1.to_f
|
60
|
-
assert_in_delta expected_time, display_time, 0.
|
59
|
+
assert_in_delta expected_time, display_time, 0.5
|
61
60
|
end
|
62
61
|
|
63
62
|
private
|
64
63
|
def print(result)
|
65
64
|
test = caller.first =~ /in `(.*)'/ ? $1 : "test"
|
66
|
-
path =
|
65
|
+
path = RubyProf.tmpdir
|
67
66
|
profile = "ruby_prof_#{test}"
|
68
67
|
printer = RubyProf::MultiPrinter.new(result)
|
69
68
|
printer.print(:path => path, :profile => profile,
|
@@ -75,6 +74,6 @@ class MultiPrinterTest < Test::Unit::TestCase
|
|
75
74
|
GC.start
|
76
75
|
GC.dump_file_and_line_info("heap.dump")
|
77
76
|
end
|
78
|
-
[File.
|
77
|
+
[File.read(printer.stack_profile), File.read(printer.graph_profile)]
|
79
78
|
end
|
80
79
|
end
|
File without changes
|
data/test/pause_resume_test.rb
CHANGED
@@ -31,6 +31,10 @@ class PauseResumeTest < Test::Unit::TestCase
|
|
31
31
|
# Kernel#sleep
|
32
32
|
|
33
33
|
methods = result.threads.first.methods.sort_by {|method_info| method_info.full_name}
|
34
|
+
# remove methods called by pause/resume
|
35
|
+
called_methods = ['Array#include?', 'Fixnum#==', 'Kernel#respond_to?', 'Kernel#respond_to_missing?']
|
36
|
+
methods.reject!{|m| called_methods.include?(m.full_name) }
|
37
|
+
# TODO: fix pause/resume to not include those methods in the first place
|
34
38
|
assert_equal(3, methods.length)
|
35
39
|
|
36
40
|
# Check the names
|
@@ -56,15 +60,12 @@ class PauseResumeTest < Test::Unit::TestCase
|
|
56
60
|
def test_pause_resume_1
|
57
61
|
profile = RubyProf::Profile.new(RubyProf::WALL_TIME,[])
|
58
62
|
|
59
|
-
# Measured
|
60
63
|
profile.start
|
61
64
|
method_1a
|
62
65
|
|
63
|
-
# Not measured
|
64
66
|
profile.pause
|
65
67
|
method_1b
|
66
68
|
|
67
|
-
# Measured
|
68
69
|
profile.resume
|
69
70
|
method_1c
|
70
71
|
|
@@ -79,11 +80,9 @@ class PauseResumeTest < Test::Unit::TestCase
|
|
79
80
|
def test_pause_resume_2
|
80
81
|
profile = RubyProf::Profile.new(RubyProf::WALL_TIME,[])
|
81
82
|
|
82
|
-
# Measured
|
83
83
|
profile.start
|
84
84
|
method_2a
|
85
85
|
|
86
|
-
# Not Measured
|
87
86
|
profile.pause
|
88
87
|
sleep 0.5
|
89
88
|
method_2b(profile)
|
@@ -98,11 +97,10 @@ class PauseResumeTest < Test::Unit::TestCase
|
|
98
97
|
def test_pause_resume_3
|
99
98
|
profile = RubyProf::Profile.new(RubyProf::WALL_TIME,[])
|
100
99
|
|
101
|
-
# Measured
|
102
100
|
profile.start
|
103
101
|
method_3a(profile)
|
104
|
-
sleep 0.5
|
105
102
|
|
103
|
+
sleep 0.5
|
106
104
|
profile.resume
|
107
105
|
method_3b
|
108
106
|
|
@@ -165,4 +163,4 @@ class PauseResumeTest < Test::Unit::TestCase
|
|
165
163
|
profile.resume; assert !profile.paused?
|
166
164
|
profile.stop ; assert !profile.paused?
|
167
165
|
end
|
168
|
-
end
|
166
|
+
end
|