ruby-prof 1.3.0 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 522834d46befbdc0f999e78d9bff9f2f98883c6bf5a15fc8d56444bf34778a72
4
- data.tar.gz: b4bf7cc5ec23482ccbcb103b6c7ab87c8614da0076d6a43f4848d6cd8aee3178
3
+ metadata.gz: 6e62266e388c4742f279cccfd909bc167b83e2b2bc3438b52254855281ec3b56
4
+ data.tar.gz: 4becfdabd8c0453c433f36fcc767a32e5ac50f295c45deaa9b9ed7e09763b8e2
5
5
  SHA512:
6
- metadata.gz: ef3c25b85260c8c3878c3dbfb5d80469731f1070ecb3d5d8c474dc8d5c149578757fcfec91af508742cdd1b1da7500a4cf7dc2670b23f3261d5689f4fcd5f27c
7
- data.tar.gz: bc891673567736bef06b12eb72514425261a678ad9d33ad709835e1e1cffd265c4657ba436a2e28486a45fa35fd678117ac2a2882c564fbfb334eb1edcec3918
6
+ metadata.gz: ecdc60504e71f9adc7bcc5df7deb3864e0fad1544cfc57ad225053a205bdb75cad3953a415834761c964e069907e232786f977f667a7492bd7521839a4663bb4
7
+ data.tar.gz: d524f3cfa338fb190b362e42d29aaa1b60d1011e84945e73dd6bfc7f5979e0d3fe8702f6135f2c5a3f67ae4dddcd1915e7ddd1db7bab70ee00d22447cb02a398
data/CHANGES CHANGED
@@ -1,3 +1,32 @@
1
+ 1.4.2 (2020-11-3)
2
+ =====================
3
+ * Do NOT use Ruby 2.7.0 and 2.7.1 with ruby-prof. A bug in those versions of ruby causes ruby-prof to
4
+ not work. Version 2.7.2 works correctly.
5
+ * Fix crash caused be reallocating an internal stack that keeps tracks of frames *after* getting a reference to the
6
+ top frame in the stack (Charlie Savage).
7
+ * Fix bug where the flat printer did not correctly report the correct measurement mode.
8
+
9
+ 1.4.1 (2020-05-14)
10
+ =====================
11
+ * Fix compiling on older versions of gcc that do not default to c99 (Charlie Savage)
12
+
13
+ 1.4.0 (2020-05-12)
14
+ =====================
15
+ * API change - remove merge_fibers support since it resulted in incorrect results or crashes (Charlie Savage)
16
+ * Fix crash when profiling memory usage (Charlie Savage)
17
+ * When tracing execution correctly print out newobj tracepoint events (Charlie Savage)
18
+ * Remove no longer needed code for building extensions (Charlie Savage)
19
+
20
+ 1.3.2 (2020-04-19)
21
+ =====================
22
+ * Fix rack profiler so it is thread safe (Charlie Savage)
23
+ * Fix loading of prebuilt binaries on mingw64 to use Ruby's major and minor version (Charlie Savage)
24
+
25
+ 1.3.1 (2020-03-11)
26
+ =====================
27
+ * Add max_percent and filter_by options to flat printer (Sean McGivern)
28
+ * Include binary in mingw64 build (Charlie Savage)
29
+
1
30
  1.3.0 (2020-02-22)
2
31
  =====================
3
32
  * Update C code to use newer RTypedData API versus older RData API.
data/Rakefile CHANGED
@@ -6,13 +6,6 @@ require "rake/testtask"
6
6
  require "rdoc/task"
7
7
  require "date"
8
8
  require "rake/clean"
9
- begin
10
- require "bundler/setup"
11
- Bundler::GemHelper.install_tasks
12
- [:build, :install, :release].each {|t| Rake::Task[t].enhance [:rdoc] }
13
- rescue LoadError
14
- $stderr.puts "Install bundler to get support for simplified gem publishing"
15
- end
16
9
 
17
10
  # To release a version of ruby-prof:
18
11
  # * Update lib/ruby-prof/version.rb
@@ -23,10 +16,6 @@ end
23
16
  # * rake package to create the gems
24
17
  # * Tag the release (git tag 0.10.1)
25
18
  # * Push to ruybgems.org (gem push pkg/<gem files>)
26
- # For a ruby only release, just run
27
- # * rake release
28
- # it will push changes to github, tag the release, build the package and upload it to rubygems.org
29
- # and in case you forgot to increment the version number or have uncommitted changes, it will refuse to work
30
19
 
31
20
  GEM_NAME = 'ruby-prof'
32
21
  SO_NAME = 'ruby_prof'
@@ -38,9 +27,9 @@ Rake::ExtensionTask.new do |ext|
38
27
  ext.gem_spec = default_spec
39
28
  ext.name = SO_NAME
40
29
  ext.ext_dir = "ext/#{SO_NAME}"
41
- ext.lib_dir = "lib/#{RUBY_VERSION}"
30
+ ext.lib_dir = "lib/#{Gem::Version.new(RUBY_VERSION).segments[0..1].join('.')}"
42
31
  ext.cross_compile = true
43
- ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
32
+ ext.cross_platform = ['x64-mingw32']
44
33
  end
45
34
 
46
35
  # Rake task to build the default package
@@ -58,7 +47,6 @@ if RUBY_PLATFORM.match(/win32|mingw32/)
58
47
  win_spec = default_spec.clone
59
48
  win_spec.platform = Gem::Platform::CURRENT
60
49
  win_spec.files += Dir.glob('lib/**/*.so')
61
- win_spec.instance_variable_set(:@cache_file, nil) # Hack to work around gem issue
62
50
 
63
51
  # Unset extensions
64
52
  win_spec.extensions = nil
@@ -1,36 +1,16 @@
1
1
  require "mkmf"
2
2
 
3
- if RUBY_ENGINE != "ruby"
4
- STDERR.puts("\n\n***** This gem is MRI-specific. It does not support #{RUBY_ENGINE}. *****\n\n")
5
- exit(1)
6
- end
7
-
8
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4.0')
9
- STDERR.puts("\n\n***** Ruby version #{RUBY_VERSION} is no longer supported. Please upgrade to 2.3 or higher. *****\n\n")
10
- exit(1)
11
- end
12
-
13
- # For the love of bitfields...
14
- $CFLAGS += ' -std=c99'
15
-
16
- # And since we are using C99
17
- CONFIG['warnflags'].gsub!('-Wdeclaration-after-statement', '')
3
+ # This function was added in Ruby 2.5, so once Ruby 2.4 is no longer supported this can be removed
4
+ have_func('rb_tracearg_callee_id', ["ruby.h"])
18
5
 
19
- def add_define(name, value = nil)
20
- if value
21
- $defs.push("-D#{name}=#{value}")
22
- else
23
- $defs.push("-D#{name}")
24
- end
6
+ # We want to intermix declarations and code (ie, don't define all variables at the top of the method)
7
+ unless RUBY_PLATFORM =~ /mswin/
8
+ $CFLAGS += ' -std=c99'
25
9
  end
26
10
 
27
- def windows?
28
- RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
11
+ # And since we are using C99 we want to disable Ruby sending these warnings to gcc
12
+ if CONFIG['warnflags']
13
+ CONFIG['warnflags'].gsub!('-Wdeclaration-after-statement', '')
29
14
  end
30
15
 
31
- add_define("RUBY_PROF_RUBY_VERSION", RUBY_VERSION.split('.')[0..2].inject(0){|v,d| v*100+d.to_i})
32
-
33
- # This function was added in Ruby 2.5, so once Ruby 2.4 is no longer supported this can be removed
34
- have_func('rb_tracearg_callee_id', ["ruby.h"])
35
-
36
16
  create_makefile("ruby_prof")
@@ -219,7 +219,7 @@ VALUE prof_call_trees_callers(VALUE self)
219
219
  }
220
220
  }
221
221
 
222
- VALUE result = rb_ary_new_capa(callers->num_entries);
222
+ VALUE result = rb_ary_new_capa((long)callers->num_entries);
223
223
  rb_st_foreach(callers, prof_call_trees_collect_aggregates, result);
224
224
  rb_st_free_table(callers);
225
225
  return result;
@@ -239,7 +239,7 @@ VALUE prof_call_trees_callees(VALUE self)
239
239
  rb_st_foreach((*call_tree)->children, prof_call_trees_collect_callees, (st_data_t)callees);
240
240
  }
241
241
 
242
- VALUE result = rb_ary_new_capa(callees->num_entries);
242
+ VALUE result = rb_ary_new_capa((long)callees->num_entries);
243
243
  rb_st_foreach(callees, prof_call_trees_collect_aggregates, result);
244
244
  rb_st_free_table(callees);
245
245
  return result;
@@ -10,7 +10,7 @@ VALUE total_allocated_objects_key;
10
10
 
11
11
  static double measure_allocations_via_gc_stats(rb_trace_arg_t* trace_arg)
12
12
  {
13
- return rb_gc_stat(total_allocated_objects_key);
13
+ return (double)rb_gc_stat(total_allocated_objects_key);
14
14
  }
15
15
 
16
16
  static double measure_allocations_via_tracing(rb_trace_arg_t* trace_arg)
@@ -24,7 +24,7 @@ static double measure_process_time(rb_trace_arg_t* trace_arg)
24
24
  userTimeInt.LowPart = userTime.dwLowDateTime;
25
25
  userTimeInt.HighPart = userTime.dwHighDateTime;
26
26
 
27
- return sysTimeInt.QuadPart + userTimeInt.QuadPart;
27
+ return (double)(sysTimeInt.QuadPart + userTimeInt.QuadPart);
28
28
  #elif !defined(CLOCK_PROCESS_CPUTIME_ID)
29
29
  struct rusage usage;
30
30
  getrusage(RUSAGE_SELF, &usage);
@@ -17,7 +17,7 @@ static double measure_wall_time(rb_trace_arg_t* trace_arg)
17
17
  #if defined(_WIN32)
18
18
  LARGE_INTEGER time;
19
19
  QueryPerformanceCounter(&time);
20
- return time.QuadPart;
20
+ return (double)time.QuadPart;
21
21
  #elif defined(__APPLE__)
22
22
  return mach_absolute_time();// * (uint64_t)mach_timebase.numer / (uint64_t)mach_timebase.denom;
23
23
  #elif defined(__linux__)
@@ -65,25 +65,19 @@ static const char* get_event_name(rb_event_flag_t event)
65
65
  return "fiber-switch";
66
66
  case RUBY_EVENT_RAISE:
67
67
  return "raise";
68
+ case RUBY_INTERNAL_EVENT_NEWOBJ:
69
+ return "newobj";
68
70
  default:
69
71
  return "unknown";
70
72
  }
71
73
  }
72
74
 
73
- VALUE get_fiber(prof_profile_t* profile)
74
- {
75
- if (profile->merge_fibers)
76
- return rb_thread_current();
77
- else
78
- return rb_fiber_current();
79
- }
80
-
81
75
  thread_data_t* check_fiber(prof_profile_t* profile, double measurement)
82
76
  {
83
77
  thread_data_t* result = NULL;
84
78
 
85
- /* Get the current thread and fiber information. */
86
- VALUE fiber = get_fiber(profile);
79
+ // Get the current fiber
80
+ VALUE fiber = rb_fiber_current();
87
81
 
88
82
  /* We need to switch the profiling context if we either had none before,
89
83
  we don't merge fibers and the fiber ids differ, or the thread ids differ. */
@@ -172,7 +166,7 @@ prof_method_t* check_method(VALUE profile, rb_trace_arg_t* trace_arg, rb_event_f
172
166
  static void prof_trace(prof_profile_t* profile, rb_trace_arg_t* trace_arg, double measurement)
173
167
  {
174
168
  static VALUE last_fiber = Qnil;
175
- VALUE fiber = get_fiber(profile);
169
+ VALUE fiber = rb_fiber_current();
176
170
 
177
171
  rb_event_flag_t event = rb_tracearg_event_flag(trace_arg);
178
172
  const char* event_name = get_event_name(event);
@@ -487,7 +481,6 @@ static VALUE prof_allocate(VALUE klass)
487
481
  profile->include_threads_tbl = NULL;
488
482
  profile->running = Qfalse;
489
483
  profile->allow_exceptions = false;
490
- profile->merge_fibers = false;
491
484
  profile->exclude_methods_tbl = method_table_create();
492
485
  profile->running = Qfalse;
493
486
  profile->tracepoints = rb_ary_new();
@@ -529,9 +522,6 @@ prof_stop_threads(prof_profile_t* profile)
529
522
  If not specified, defaults to RubyProf::WALL_TIME.
530
523
  allow_exceptions: Whether to raise exceptions encountered during profiling,
531
524
  or to suppress all exceptions during profiling
532
- merge_fibers: Whether profiling data for a given thread's fibers should all be
533
- subsumed under a single entry. Basically only useful to produce
534
- callgrind profiles.
535
525
  track_allocations: Whether to track object allocations while profiling. True or false.
536
526
  exclude_common: Exclude common methods from the profile. True or false.
537
527
  exclude_threads: Threads to exclude from the profiling results.
@@ -546,7 +536,6 @@ static VALUE prof_initialize(int argc, VALUE* argv, VALUE self)
546
536
  VALUE include_threads = Qnil;
547
537
  VALUE exclude_common = Qnil;
548
538
  VALUE allow_exceptions = Qfalse;
549
- VALUE merge_fibers = Qfalse;
550
539
  VALUE track_allocations = Qfalse;
551
540
 
552
541
  int i;
@@ -566,7 +555,6 @@ static VALUE prof_initialize(int argc, VALUE* argv, VALUE self)
566
555
  mode = rb_hash_aref(mode_or_options, ID2SYM(rb_intern("measure_mode")));
567
556
  track_allocations = rb_hash_aref(mode_or_options, ID2SYM(rb_intern("track_allocations")));
568
557
  allow_exceptions = rb_hash_aref(mode_or_options, ID2SYM(rb_intern("allow_exceptions")));
569
- merge_fibers = rb_hash_aref(mode_or_options, ID2SYM(rb_intern("merge_fibers")));
570
558
  exclude_common = rb_hash_aref(mode_or_options, ID2SYM(rb_intern("exclude_common")));
571
559
  exclude_threads = rb_hash_aref(mode_or_options, ID2SYM(rb_intern("exclude_threads")));
572
560
  include_threads = rb_hash_aref(mode_or_options, ID2SYM(rb_intern("include_threads")));
@@ -587,7 +575,6 @@ static VALUE prof_initialize(int argc, VALUE* argv, VALUE self)
587
575
  }
588
576
  profile->measurer = prof_get_measurer(NUM2INT(mode), track_allocations == Qtrue);
589
577
  profile->allow_exceptions = (allow_exceptions == Qtrue);
590
- profile->merge_fibers = (merge_fibers == Qtrue);
591
578
 
592
579
  if (exclude_threads != Qnil)
593
580
  {
@@ -679,7 +666,7 @@ static VALUE prof_start(VALUE self)
679
666
 
680
667
  profile->running = Qtrue;
681
668
  profile->paused = Qfalse;
682
- profile->last_thread_data = threads_table_insert(profile, get_fiber(profile));
669
+ profile->last_thread_data = threads_table_insert(profile, rb_fiber_current());
683
670
 
684
671
  /* open trace file if environment wants it */
685
672
  trace_file_name = getenv("RUBY_PROF_TRACE");
@@ -769,11 +756,7 @@ static VALUE prof_stop(VALUE self)
769
756
  {
770
757
  if (trace_file != stderr && trace_file != stdout)
771
758
  {
772
- #ifdef _MSC_VER
773
- _fcloseall();
774
- #else
775
759
  fclose(trace_file);
776
- #endif
777
760
  }
778
761
  trace_file = NULL;
779
762
  }
@@ -26,7 +26,6 @@ typedef struct prof_profile_t
26
26
  thread_data_t* last_thread_data;
27
27
  double measurement_at_pause_resume;
28
28
  bool allow_exceptions;
29
- bool merge_fibers;
30
29
  } prof_profile_t;
31
30
 
32
31
  void rp_init_profile(void);
@@ -22,6 +22,14 @@ void prof_stack_free(prof_stack_t* stack)
22
22
  xfree(stack);
23
23
  }
24
24
 
25
+ prof_frame_t* prof_stack_parent(prof_stack_t* stack)
26
+ {
27
+ if (stack->ptr == stack->start || stack->ptr - 1 == stack->start)
28
+ return NULL;
29
+ else
30
+ return stack->ptr - 2;
31
+ }
32
+
25
33
  prof_frame_t* prof_stack_last(prof_stack_t* stack)
26
34
  {
27
35
  if (stack->ptr == stack->start)
@@ -86,8 +94,8 @@ prof_frame_t* prof_frame_current(prof_stack_t* stack)
86
94
 
87
95
  prof_frame_t* prof_frame_push(prof_stack_t* stack, prof_call_tree_t* call_tree, double measurement, bool paused)
88
96
  {
89
- prof_frame_t* parent_frame = prof_stack_last(stack);
90
97
  prof_frame_t* result = prof_stack_push(stack);
98
+ prof_frame_t* parent_frame = prof_stack_parent(stack);
91
99
 
92
100
  result->call_tree = call_tree;
93
101
 
@@ -129,7 +137,7 @@ prof_frame_t* prof_frame_push(prof_stack_t* stack, prof_call_tree_t* call_tree,
129
137
  prof_frame_t* prof_frame_unshift(prof_stack_t* stack, prof_call_tree_t* parent_call_tree, prof_call_tree_t* call_tree, double measurement)
130
138
  {
131
139
  if (prof_stack_last(stack))
132
- rb_raise(rb_eRuntimeError, "Stach unshift can only be called with an empty stack");
140
+ rb_raise(rb_eRuntimeError, "Stack unshift can only be called with an empty stack");
133
141
 
134
142
  parent_call_tree->measurement->total_time = call_tree->measurement->total_time;
135
143
  parent_call_tree->measurement->self_time = 0;
@@ -187,7 +195,7 @@ prof_frame_t* prof_frame_pop(prof_stack_t* stack, double measurement)
187
195
 
188
196
  prof_method_t* prof_find_method(prof_stack_t* stack, VALUE source_file, int source_line)
189
197
  {
190
- prof_frame_t* frame = stack->ptr;
198
+ prof_frame_t* frame = prof_stack_last(stack);
191
199
  while (frame >= stack->start)
192
200
  {
193
201
  if (!frame->call_tree)
@@ -7,16 +7,24 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ruby_prof", "ruby_prof.vcxp
7
7
  EndProject
8
8
  Global
9
9
  GlobalSection(SolutionConfigurationPlatforms) = preSolution
10
+ Debug|ARM = Debug|ARM
11
+ Debug|ARM64 = Debug|ARM64
10
12
  Debug|x64 = Debug|x64
11
13
  Debug|x86 = Debug|x86
14
+ Release|ARM = Release|ARM
15
+ Release|ARM64 = Release|ARM64
12
16
  Release|x64 = Release|x64
13
17
  Release|x86 = Release|x86
14
18
  EndGlobalSection
15
19
  GlobalSection(ProjectConfigurationPlatforms) = postSolution
20
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|ARM.ActiveCfg = Debug|Win32
21
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|ARM64.ActiveCfg = Debug|Win32
16
22
  {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|x64.ActiveCfg = Debug|x64
17
23
  {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|x64.Build.0 = Debug|x64
18
24
  {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|x86.ActiveCfg = Debug|Win32
19
25
  {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|x86.Build.0 = Debug|Win32
26
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|ARM.ActiveCfg = Release|Win32
27
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|ARM64.ActiveCfg = Release|Win32
20
28
  {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|x64.ActiveCfg = Release|x64
21
29
  {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|x64.Build.0 = Release|x64
22
30
  {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|x86.ActiveCfg = Release|Win32
@@ -64,7 +64,7 @@
64
64
  </PropertyGroup>
65
65
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
66
66
  <TargetExt>.so</TargetExt>
67
- <OutDir>..\..\..\lib</OutDir>
67
+ <OutDir>..\..\..\lib\</OutDir>
68
68
  </PropertyGroup>
69
69
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
70
70
  <ClCompile>
@@ -102,17 +102,28 @@
102
102
  </ItemDefinitionGroup>
103
103
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
104
104
  <ClCompile>
105
- <AdditionalIncludeDirectories>C:\msys64\usr\local\ruby-2.7.0vc\include\ruby-2.7.0\x64-mswin64_140;C:\msys64\usr\local\ruby-2.7.0vc\include\ruby-2.7.0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
105
+ <AdditionalIncludeDirectories>C:\msys64\usr\local\ruby-2.7.2vc\include\ruby-2.7.0\x64-mswin64_140;C:\msys64\usr\local\ruby-2.7.2vc\include\ruby-2.7.0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
106
106
  <Optimization>Disabled</Optimization>
107
107
  <PreprocessorDefinitions>HAVE_RB_TRACEARG_CALLEE_ID;%(PreprocessorDefinitions)</PreprocessorDefinitions>
108
+ <WarningLevel>Level3</WarningLevel>
108
109
  </ClCompile>
109
110
  <Link>
110
- <AdditionalLibraryDirectories>C:\msys64\usr\local\ruby-2.7.0vc\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
111
+ <AdditionalLibraryDirectories>C:\msys64\usr\local\ruby-2.7.2vc\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
111
112
  <AdditionalDependencies>x64-vcruntime140-ruby270.lib;%(AdditionalDependencies)</AdditionalDependencies>
112
113
  <ModuleDefinitionFile>ruby_prof.def</ModuleDefinitionFile>
113
114
  <SubSystem>Console</SubSystem>
114
115
  </Link>
115
116
  </ItemDefinitionGroup>
117
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
118
+ <ClCompile>
119
+ <AdditionalIncludeDirectories>C:\msys64\usr\local\ruby-2.7.1vc\include\ruby-2.7.0\x64-mswin64_140;C:\msys64\usr\local\ruby-2.7.1vc\include\ruby-2.7.0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
120
+ </ClCompile>
121
+ <Link>
122
+ <AdditionalLibraryDirectories>C:\msys64\usr\local\ruby-2.7.1vc\lib</AdditionalLibraryDirectories>
123
+ <AdditionalDependencies>x64-vcruntime140-ruby270.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
124
+ <ModuleDefinitionFile>ruby_prof.def</ModuleDefinitionFile>
125
+ </Link>
126
+ </ItemDefinitionGroup>
116
127
  <ItemGroup>
117
128
  <ClInclude Include="..\rp_aggregate_call_tree.h" />
118
129
  <ClInclude Include="..\rp_allocation.h" />
@@ -1,9 +1,10 @@
1
1
  # encoding: utf-8
2
+ require 'rubygems/version'
2
3
 
3
4
  # Load the C-based binding.
4
5
  begin
5
- RUBY_VERSION =~ /(\d+\.\d+\.\d+)/
6
- require "#{$1}/ruby_prof.so"
6
+ version = Gem::Version.new(RUBY_VERSION)
7
+ require "#{version.segments[0..1].join('.')}/ruby_prof.so"
7
8
  rescue LoadError
8
9
  require "ruby_prof.so"
9
10
  end
@@ -81,16 +81,6 @@ module RubyProf
81
81
  Profile.profile(options, &block)
82
82
  end
83
83
 
84
- # :nodoc:
85
- def self.measure_mode_string
86
- case measure_mode
87
- when WALL_TIME then "wall_time"
88
- when PROCESS_TIME then "process_time"
89
- when ALLOCATIONS then "allocations"
90
- when MEMORY then "memory"
91
- end
92
- end
93
-
94
84
  # :nodoc:
95
85
  def self.start_script(script)
96
86
  start
@@ -17,11 +17,21 @@ module RubyProf
17
17
  @output = nil
18
18
  end
19
19
 
20
- # Returns the min_percent of total time a method must take to be included in a profiling report
20
+ # Returns the min_percent of time a method must take to be included in a profiling report
21
21
  def min_percent
22
22
  @options[:min_percent] || 0
23
23
  end
24
24
 
25
+ # Returns the max_percent of time a method can take to be included in a profiling report
26
+ def max_percent
27
+ @options[:max_percent] || 100
28
+ end
29
+
30
+ # Returns the method to filter methods by (when using min_percent and max_percent)
31
+ def filter_by
32
+ @options[:filter_by] || :self_time
33
+ end
34
+
25
35
  # Returns the time format used to show when a profile was run
26
36
  def time_format
27
37
  '%A, %B %-d at %l:%M:%S %p (%Z)'
@@ -89,7 +99,7 @@ module RubyProf
89
99
  end
90
100
 
91
101
  def print_header(thread)
92
- @output << "Measure Mode: %s\n" % RubyProf.measure_mode_string
102
+ @output << "Measure Mode: %s\n" % @result.measure_mode_string
93
103
  @output << "Thread ID: %d\n" % thread.id
94
104
  @output << "Fiber ID: %d\n" % thread.fiber_id unless thread.id == thread.fiber_id
95
105
  @output << "Total: %0.6f\n" % thread.total_time