ruby-prof 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'date'
6
6
 
7
7
  # ------- Version ----
8
8
  # Read version from header file
9
- version_header = File.read('ext/version.h')
9
+ version_header = File.read('ext/ruby_prof/version.h')
10
10
  match = version_header.match(/RUBY_PROF_VERSION\s*["](\d.+)["]/)
11
11
  raise(RuntimeError, "Could not determine RUBY_PROF_VERSION") if not match
12
12
  RUBY_PROF_VERSION = match[1]
@@ -21,9 +21,10 @@ FILES = FileList[
21
21
  'bin/*',
22
22
  'doc/**/*',
23
23
  'examples/*',
24
- 'ext/*',
25
- 'ext/mingw/Rakefile',
26
- 'ext/mingw/build.rake',
24
+ 'ext/ruby_prof/*.c',
25
+ 'ext/ruby_prof/*.h',
26
+ 'ext/ruby_prof/mingw/Rakefile',
27
+ 'ext/ruby_prof/mingw/build.rake',
27
28
  'ext/vc/*.sln',
28
29
  'ext/vc/*.vcproj',
29
30
  'lib/**/*',
@@ -54,18 +55,28 @@ EOF
54
55
  spec.require_path = "lib"
55
56
  spec.bindir = "bin"
56
57
  spec.executables = ["ruby-prof"]
57
- spec.extensions = ["ext/extconf.rb"]
58
+ spec.extensions = ["ext/ruby_prof/extconf.rb"]
58
59
  spec.files = FILES.to_a
59
60
  spec.test_files = Dir["test/test_*.rb"]
60
-
61
-
62
61
  spec.required_ruby_version = '>= 1.8.4'
63
62
  spec.date = DateTime.now
64
63
  spec.rubyforge_project = 'ruby-prof'
65
64
  spec.add_development_dependency 'os'
65
+ spec.add_development_dependency 'rake-compiler'
66
66
 
67
67
  end
68
68
 
69
+
70
+ desc 'build native .gem files -- use like "native_gems clobber cross native gem"--for non native gem creation use "native_gems clobber" then "clean gem"'
71
+ task :native_gems do
72
+ ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
73
+ require 'rake/extensiontask'
74
+ Rake::ExtensionTask.new('ruby_prof', default_spec) do |ext|
75
+ ext.cross_compile = true
76
+ ext.cross_platform = ['x86-mswin32-60', 'x86-mingw32-60']
77
+ end
78
+ end
79
+
69
80
  # Rake task to build the default package
70
81
  Rake::GemPackageTask.new(default_spec) do |pkg|
71
82
  pkg.need_tar = true
@@ -73,22 +84,6 @@ Rake::GemPackageTask.new(default_spec) do |pkg|
73
84
  end
74
85
 
75
86
 
76
- # ------- Windows Package ----------
77
- if RUBY_PLATFORM.match(/win32/)
78
- binaries = (FileList['ext/mingw/*.so',
79
- 'ext/mingw/*.dll*'])
80
-
81
- # Windows specification
82
- win_spec = default_spec.clone
83
- win_spec.extensions = ['ext/mingw/Rakefile']
84
- win_spec.platform = Gem::Platform::CURRENT
85
- win_spec.files += binaries.to_a
86
-
87
- # Rake task to build the windows package
88
- Rake::GemPackageTask.new(win_spec) do |pkg|
89
- end
90
- end
91
-
92
87
  # --------- RDoc Documentation ------
93
88
  desc "Generate rdoc documentation"
94
89
  Rake::RDocTask.new("rdoc") do |rdoc|
@@ -104,9 +99,9 @@ Rake::RDocTask.new("rdoc") do |rdoc|
104
99
  'examples/graph.txt',
105
100
  'examples/graph.html',
106
101
  'lib/**/*.rb',
107
- 'ext/ruby_prof.c',
108
- 'ext/version.h',
109
- 'ext/measure_*.h',
102
+ 'ext/ruby_prof/ruby_prof.c',
103
+ 'ext/ruby_prof/version.h',
104
+ 'ext/ruby_prof/measure_*.h',
110
105
  'README',
111
106
  'LICENSE')
112
107
  end
@@ -129,7 +124,7 @@ task :build do
129
124
  end
130
125
 
131
126
  def build(with_debug)
132
- Dir.chdir('ext') do
127
+ Dir.chdir('ext/ruby_prof') do
133
128
  unless File.exist? 'Makefile'
134
129
  if with_debug
135
130
  system(Gem.ruby + " -d extconf.rb")
@@ -139,18 +134,20 @@ def build(with_debug)
139
134
  system("make clean")
140
135
  end
141
136
  system("make")
142
- FileUtils.cp 'ruby_prof.so', '../lib'
137
+ FileUtils.cp 'ruby_prof.so', '../../lib'
143
138
  end
144
139
  end
145
140
 
146
- desc 'build ruby_prof.so with verbose symbols enabled'
141
+ desc 'build ruby_prof.so with (rather verbose) debugging enabled'
142
+
147
143
  task :build_debug do
148
144
  build(true)
149
145
  end
150
146
 
151
- task :clean do
147
+ desc 'clean stuff'
148
+ task :cleanr do
152
149
  FileUtils.rm 'lib/ruby_prof.so' if File.exist? 'lib/ruby_prof.so'
153
- Dir.chdir('ext') do
150
+ Dir.chdir('ext/ruby_prof') do
154
151
  if File.exist? 'Makefile'
155
152
  system("make clean")
156
153
  FileUtils.rm 'Makefile'
@@ -160,4 +157,4 @@ task :clean do
160
157
  end
161
158
  end
162
159
  system("rm -rf pkg")
163
- end
160
+ end
@@ -31,10 +31,14 @@ have_func("rb_gc_heap_info")
31
31
  have_func("rb_gc_malloc_allocations")
32
32
  have_func("rb_gc_malloc_allocated_size")
33
33
 
34
- def add_define(name)
35
- $defs.push("-D#{name}")
34
+ def add_define(name, value = nil)
35
+ if value
36
+ $defs.push("-D#{name}=#{value}")
37
+ else
38
+ $defs.push("-D#{name}")
39
+ end
36
40
  end
37
41
 
38
42
  add_define 'DEBUG' if $DEBUG
39
-
43
+ add_define("RUBY_VERSION", RUBY_VERSION.gsub('.', ''))
40
44
  create_makefile("ruby_prof")
@@ -29,7 +29,7 @@
29
29
  #if defined(_WIN32) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__ppc__)))
30
30
  #define MEASURE_CPU_TIME 2
31
31
 
32
- static unsigned long long cpu_frequency;
32
+ static unsigned LONG_LONG cpu_frequency;
33
33
 
34
34
  #if defined(__GNUC__)
35
35
 
@@ -93,10 +93,10 @@ unsigned long long get_cpu_frequency()
93
93
 
94
94
  #elif defined(_WIN32)
95
95
 
96
- unsigned long long get_cpu_frequency()
96
+ unsigned LONG_LONG get_cpu_frequency()
97
97
  {
98
- unsigned long long x, y;
99
- unsigned long long frequency;
98
+ unsigned LONG_LONG x, y;
99
+ unsigned LONG_LONG frequency;
100
100
  x = measure_cpu_time();
101
101
 
102
102
  /* Use the windows sleep function, not Ruby's */
File without changes
File without changes
@@ -1023,14 +1023,21 @@ prof_pop_threads()
1023
1023
  st_foreach(threads_tbl, pop_frames, (st_data_t) &now);
1024
1024
  }
1025
1025
 
1026
+ #if RUBY_VERSION == 190
1027
+ # error 1.9.0 not supported (ask for it if desired)
1028
+ #endif
1026
1029
 
1027
- #ifdef RUBY_VM
1030
+ #if RUBY_VERSION == 191
1031
+
1032
+ /* Avoid bugs in 1.9.1 */
1028
1033
 
1029
- /* These are mostly to avoid bugs in core */
1030
1034
  static inline void walk_up_until_right_frame(prof_frame_t *frame, thread_data_t* thread_data, ID mid, VALUE klass, prof_measure_t now);
1031
1035
  void prof_install_hook();
1032
1036
  void prof_remove_hook();
1033
1037
 
1038
+ #endif
1039
+
1040
+ #ifdef RUBY_VM
1034
1041
  static void
1035
1042
  prof_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE klass)
1036
1043
  #else
@@ -1095,7 +1102,7 @@ prof_event_hook(rb_event_flag_t event, NODE *node, VALUE self, ID mid, VALUE kla
1095
1102
  thread = rb_thread_current();
1096
1103
  thread_id = rb_obj_id(thread);
1097
1104
 
1098
- # ifdef RUBY_VM
1105
+ # if RUBY_VERSION == 191
1099
1106
  /* ensure that new threads are hooked [sigh] (bug in core) */
1100
1107
  prof_remove_hook();
1101
1108
  prof_install_hook();
@@ -1129,8 +1136,8 @@ prof_event_hook(rb_event_flag_t event, NODE *node, VALUE self, ID mid, VALUE kla
1129
1136
  {
1130
1137
  frame->line = rb_sourceline();
1131
1138
 
1132
- # ifdef RUBY_VM
1133
- // disabled till I figure out why it causes
1139
+ # if RUBY_VERSION == 191
1140
+ // disabled it causes
1134
1141
  // us to lose valuable frame information...maybe mid comes in wrong sometimes?
1135
1142
  // walk_up_until_right_frame(frame, thread_data, mid, klass, now);
1136
1143
  # endif
@@ -1145,11 +1152,12 @@ prof_event_hook(rb_event_flag_t event, NODE *node, VALUE self, ID mid, VALUE kla
1145
1152
  case RUBY_EVENT_CALL:
1146
1153
  case RUBY_EVENT_C_CALL:
1147
1154
  {
1148
- /* Get the current frame for the current thread. */
1149
- frame = stack_peek(thread_data->stack);
1150
1155
  prof_call_info_t *call_info = NULL;
1151
1156
  prof_method_t *method = NULL;
1152
1157
 
1158
+ /* Get the current frame for the current thread. */
1159
+ frame = stack_peek(thread_data->stack);
1160
+
1153
1161
  /* Is this an include for a module? If so get the actual
1154
1162
  module class since we want to combine all profiling
1155
1163
  results for that module. */
@@ -1206,7 +1214,7 @@ prof_event_hook(rb_event_flag_t event, NODE *node, VALUE self, ID mid, VALUE kla
1206
1214
  {
1207
1215
  frame = pop_frame(thread_data, now);
1208
1216
 
1209
- # ifdef RUBY_VM
1217
+ # if RUBY_VERSION == 191
1210
1218
  // we need to walk up the stack to find the right one [http://redmine.ruby-lang.org/issues/show/2610] (for now)
1211
1219
  // sometimes frames don't have line and source somehow [like blank]
1212
1220
  // if we hit one there's not much we can do...I guess...
@@ -1219,7 +1227,7 @@ prof_event_hook(rb_event_flag_t event, NODE *node, VALUE self, ID mid, VALUE kla
1219
1227
  }
1220
1228
  }
1221
1229
 
1222
- #ifdef RUBY_VM
1230
+ #if RUBY_VERSION == 191
1223
1231
 
1224
1232
  static inline void walk_up_until_right_frame(prof_frame_t *frame, thread_data_t* thread_data, ID mid, VALUE klass, prof_measure_t now) {
1225
1233
  // while it doesn't match, pop on up until we have found where we belong...
File without changes
@@ -0,0 +1,4 @@
1
+ #define RUBY_PROF_VERSION "0.8.2"
2
+ #define RUBY_PROF_VERSION_MAJ 0
3
+ #define RUBY_PROF_VERSION_MIN 8
4
+ #define RUBY_PROF_VERSION_MIC 2
data/lib/ruby-prof.rb CHANGED
@@ -1,4 +1,11 @@
1
- require File.dirname(__FILE__) + "/../ext/ruby_prof" # .so
1
+ # require the .so file
2
+ me = File.dirname(__FILE__) + '/'
3
+ begin
4
+ # fat binaries
5
+ require "#{me}/#{RUBY_VERSION[0..2]}/ruby_prof"
6
+ rescue Exception
7
+ require "#{me}/../ext/ruby_prof/ruby_prof"
8
+ end
2
9
 
3
10
  require "ruby-prof/method_info"
4
11
  require "ruby-prof/call_info"
@@ -46,4 +53,4 @@ module RubyProf
46
53
  end
47
54
  end
48
55
 
49
- RubyProf::figure_measure_mode
56
+ RubyProf::figure_measure_mode
@@ -55,15 +55,11 @@ module RubyProf
55
55
  File.expand_path(method.source_file)
56
56
  end
57
57
 
58
- def name(method)
59
- "#{method.klass_name}::#{method.method_name}"
60
- end
61
-
62
58
  def print_methods(thread_id, methods)
63
59
  methods.reverse_each do |method|
64
60
  # Print out the file and method name
65
61
  @output << "fl=#{file(method)}\n"
66
- @output << "fn=#{name(method)}\n"
62
+ @output << "fn=#{method_name(method)}\n"
67
63
 
68
64
  # Now print out the function line number and its self time
69
65
  @output << "#{method.line} #{convert(method.self_time)}\n"
@@ -71,7 +67,7 @@ module RubyProf
71
67
  # Now print out all the children methods
72
68
  method.children.each do |callee|
73
69
  @output << "cfl=#{file(callee.target)}\n"
74
- @output << "cfn=#{name(callee.target)}\n"
70
+ @output << "cfn=#{method_name(callee.target)}\n"
75
71
  @output << "calls=#{callee.called} #{callee.line}\n"
76
72
 
77
73
  # Print out total times here!
data/lib/ruby_prof.so ADDED
Binary file
@@ -1,8 +1,8 @@
1
1
  1.8 passes, 1.9 however...
2
2
 
3
3
  1) Failure:
4
- test_thread_timings(ThreadTest) [E:/dev/ruby/ruby-prof/test/thread_test.rb:76]:
5
- Expected 0 - 1.0 (1.0) to be < 0.01.
4
+ test_flat_string_with_numbers(PrintersTest) [E:/dev/ruby/ruby-prof/test/printers_test.rb:68]:
5
+ <2> expected but was
6
+ <29>.
6
7
 
7
- 43 tests, 410 assertions, 1 failures, 0 errors, 0 skips
8
- rake aborted!
8
+ which is expected until core backports a recent fix.
@@ -33,8 +33,9 @@ class PrintersTest < Test::Unit::TestCase
33
33
  printer.print
34
34
 
35
35
  printer = RubyProf::CallTreePrinter.new(@result)
36
- printer.print(STDOUT)
37
- # we should get here
36
+ printer.print(STDOUT)
37
+
38
+ # we should get here
38
39
  end
39
40
 
40
41
  def test_flat_string
@@ -94,9 +95,9 @@ class PrintersTest < Test::Unit::TestCase
94
95
  output = ''
95
96
  printer = RubyProf::CallTreePrinter.new(@result)
96
97
  printer.print(output)
97
-
98
- assert_match(/fn=Object::find_primes/i, output)
98
+ assert_match(/fn=Object#find_primes/i, output)
99
99
  assert_match(/events: wall_time/i, output)
100
+ assert_no_match(/d\d\d\d\d\d/, output) # old bug looked [in error] like Object::run_primes(d5833116)
100
101
  end
101
102
 
102
103
  def do_nothing
data/test/stack_test.rb CHANGED
@@ -107,10 +107,10 @@ class StackTest < Test::Unit::TestCase
107
107
  method = methods[3]
108
108
  assert_equal('StackClass#c', method.full_name)
109
109
  assert_equal(1, method.called)
110
- assert_in_delta(5, method.total_time, 0.01)
110
+ assert_in_delta(5, method.total_time, 0.05)
111
111
  assert_in_delta(0, method.wait_time, 0.01)
112
112
  assert_in_delta(0, method.self_time, 0.01)
113
- assert_in_delta(5, method.children_time, 0.01)
113
+ assert_in_delta(5, method.children_time, 0.05)
114
114
  assert_equal(1, method.call_infos.length)
115
115
 
116
116
  call_info = method.call_infos[0]
@@ -121,10 +121,10 @@ class StackTest < Test::Unit::TestCase
121
121
  method = methods[4]
122
122
  assert_equal('StackClass#b', method.full_name)
123
123
  assert_equal(2, method.called)
124
- assert_in_delta(4, method.total_time, 0.01)
124
+ assert_in_delta(4, method.total_time, 0.05)
125
125
  assert_in_delta(0, method.wait_time, 0.01)
126
126
  assert_in_delta(0, method.self_time, 0.01)
127
- assert_in_delta(4, method.children_time, 0.01)
127
+ assert_in_delta(4, method.children_time, 0.05)
128
128
  assert_equal(2, method.call_infos.length)
129
129
 
130
130
  call_info = method.call_infos[0]
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-prof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ hash: 59
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 8
9
+ - 2
10
+ version: 0.8.2
5
11
  platform: ruby
6
12
  authors:
7
13
  - Shugo Maeda, Charlie Savage, Roger Pack
@@ -9,19 +15,37 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-02-03 00:00:00 -07:00
18
+ date: 2010-07-09 00:00:00 -06:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: os
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
17
33
  type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rake-compiler
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
20
40
  requirements:
21
41
  - - ">="
22
42
  - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
23
46
  version: "0"
24
- version:
47
+ type: :development
48
+ version_requirements: *id002
25
49
  description: |
26
50
  ruby-prof is a fast code profiler for Ruby. It is a C extension and
27
51
  therefore is many times faster than the standard Ruby profiler. It
@@ -34,7 +58,7 @@ email: shugo@ruby-lang.org, cfis@savagexi.com, rogerdpack@gmail.com
34
58
  executables:
35
59
  - ruby-prof
36
60
  extensions:
37
- - ext/extconf.rb
61
+ - ext/ruby_prof/extconf.rb
38
62
  extra_rdoc_files: []
39
63
 
40
64
  files:
@@ -42,27 +66,22 @@ files:
42
66
  - README
43
67
  - LICENSE
44
68
  - CHANGES
45
- - bin/go.rb
46
69
  - bin/ruby-prof
47
70
  - examples/flat.txt
48
71
  - examples/graph.html
49
72
  - examples/graph.txt
50
- - ext/extconf.rb
51
- - ext/measure_allocations.h
52
- - ext/measure_cpu_time.h
53
- - ext/measure_gc_runs.h
54
- - ext/measure_gc_time.h
55
- - ext/measure_memory.h
56
- - ext/measure_process_time.h
57
- - ext/measure_wall_time.h
58
- - ext/ruby186gc.patch
59
- - ext/ruby_prof.c
60
- - ext/ruby_prof.h
61
- - ext/version.h
62
- - ext/mingw/Rakefile
63
- - ext/mingw/build.rake
64
- - ext/vc/ruby_prof.sln
65
- - ext/vc/ruby_prof.vcproj
73
+ - ext/ruby_prof/ruby_prof.c
74
+ - ext/ruby_prof/measure_allocations.h
75
+ - ext/ruby_prof/measure_cpu_time.h
76
+ - ext/ruby_prof/measure_gc_runs.h
77
+ - ext/ruby_prof/measure_gc_time.h
78
+ - ext/ruby_prof/measure_memory.h
79
+ - ext/ruby_prof/measure_process_time.h
80
+ - ext/ruby_prof/measure_wall_time.h
81
+ - ext/ruby_prof/ruby_prof.h
82
+ - ext/ruby_prof/version.h
83
+ - ext/ruby_prof/mingw/Rakefile
84
+ - ext/ruby_prof/mingw/build.rake
66
85
  - lib/ruby-prof/abstract_printer.rb
67
86
  - lib/ruby-prof/aggregate_call_info.rb
68
87
  - lib/ruby-prof/call_info.rb
@@ -76,6 +95,7 @@ files:
76
95
  - lib/ruby-prof/task.rb
77
96
  - lib/ruby-prof/test.rb
78
97
  - lib/ruby-prof.rb
98
+ - lib/ruby_prof.so
79
99
  - lib/unprof.rb
80
100
  - rails/environment/profile.rb
81
101
  - rails/example/example_test.rb
@@ -104,6 +124,7 @@ files:
104
124
  - test/test_suite.rb
105
125
  - test/thread_test.rb
106
126
  - test/unique_call_path_test.rb
127
+ - ext/ruby_prof/extconf.rb
107
128
  has_rdoc: true
108
129
  homepage: http://rubyforge.org/projects/ruby-prof/
109
130
  licenses: []
@@ -114,21 +135,29 @@ rdoc_options: []
114
135
  require_paths:
115
136
  - lib
116
137
  required_ruby_version: !ruby/object:Gem::Requirement
138
+ none: false
117
139
  requirements:
118
140
  - - ">="
119
141
  - !ruby/object:Gem::Version
142
+ hash: 63
143
+ segments:
144
+ - 1
145
+ - 8
146
+ - 4
120
147
  version: 1.8.4
121
- version:
122
148
  required_rubygems_version: !ruby/object:Gem::Requirement
149
+ none: false
123
150
  requirements:
124
151
  - - ">="
125
152
  - !ruby/object:Gem::Version
153
+ hash: 3
154
+ segments:
155
+ - 0
126
156
  version: "0"
127
- version:
128
157
  requirements: []
129
158
 
130
159
  rubyforge_project: ruby-prof
131
- rubygems_version: 1.3.5
160
+ rubygems_version: 1.3.7
132
161
  signing_key:
133
162
  specification_version: 3
134
163
  summary: Fast Ruby profiler