ruby-prof 0.10.8 → 0.11.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/CHANGES +38 -18
  2. data/LICENSE +4 -3
  3. data/README.rdoc +30 -66
  4. data/Rakefile +47 -54
  5. data/bin/ruby-prof +24 -4
  6. data/ext/ruby_prof/extconf.rb +9 -16
  7. data/ext/ruby_prof/rp_call_info.c +369 -0
  8. data/ext/ruby_prof/rp_call_info.h +46 -0
  9. data/ext/ruby_prof/rp_measure.c +48 -0
  10. data/ext/ruby_prof/rp_measure.h +45 -0
  11. data/ext/ruby_prof/rp_measure_allocations.c +86 -0
  12. data/ext/ruby_prof/rp_measure_cpu_time.c +112 -0
  13. data/ext/ruby_prof/rp_measure_gc_runs.c +87 -0
  14. data/ext/ruby_prof/rp_measure_gc_time.c +73 -0
  15. data/ext/ruby_prof/rp_measure_memory.c +81 -0
  16. data/ext/ruby_prof/rp_measure_process_time.c +71 -0
  17. data/ext/ruby_prof/rp_measure_wall_time.c +42 -0
  18. data/ext/ruby_prof/rp_method.c +363 -0
  19. data/ext/ruby_prof/rp_method.h +55 -0
  20. data/ext/ruby_prof/rp_stack.c +61 -0
  21. data/ext/ruby_prof/rp_stack.h +40 -0
  22. data/ext/ruby_prof/rp_thread.c +113 -0
  23. data/ext/ruby_prof/rp_thread.h +20 -0
  24. data/ext/ruby_prof/ruby_prof.c +259 -1398
  25. data/ext/ruby_prof/ruby_prof.h +54 -190
  26. data/ext/ruby_prof/version.h +6 -3
  27. data/lib/1.8/ruby_prof.so +0 -0
  28. data/lib/1.9/ruby_prof.exp +0 -0
  29. data/lib/1.9/ruby_prof.ilk +0 -0
  30. data/lib/1.9/ruby_prof.lib +0 -0
  31. data/lib/1.9/ruby_prof.pdb +0 -0
  32. data/lib/1.9/ruby_prof.so +0 -0
  33. data/lib/ruby-prof.rb +14 -11
  34. data/lib/ruby-prof/abstract_printer.rb +10 -0
  35. data/lib/ruby-prof/aggregate_call_info.rb +2 -0
  36. data/lib/ruby-prof/call_info.rb +2 -0
  37. data/lib/ruby-prof/call_stack_printer.rb +2 -4
  38. data/lib/ruby-prof/call_tree_printer.rb +1 -0
  39. data/lib/ruby-prof/compatibility.rb +134 -0
  40. data/lib/ruby-prof/dot_printer.rb +7 -7
  41. data/lib/ruby-prof/flat_printer.rb +7 -7
  42. data/lib/ruby-prof/flat_printer_with_line_numbers.rb +2 -5
  43. data/lib/ruby-prof/graph_html_printer.rb +4 -2
  44. data/lib/ruby-prof/graph_printer.rb +4 -3
  45. data/lib/ruby-prof/method_info.rb +2 -0
  46. data/lib/ruby-prof/multi_printer.rb +2 -0
  47. data/lib/ruby-prof/{result.rb → profile.rb} +3 -1
  48. data/lib/ruby-prof/rack.rb +1 -0
  49. data/lib/ruby-prof/symbol_to_proc.rb +2 -0
  50. data/lib/ruby-prof/task.rb +1 -0
  51. data/lib/ruby-prof/test.rb +2 -0
  52. data/lib/ruby_prof.exp +0 -0
  53. data/lib/ruby_prof.ilk +0 -0
  54. data/lib/ruby_prof.lib +0 -0
  55. data/lib/ruby_prof.pdb +0 -0
  56. data/lib/ruby_prof.so +0 -0
  57. data/lib/unprof.rb +2 -0
  58. data/test/aggregate_test.rb +8 -8
  59. data/test/basic_test.rb +3 -251
  60. data/test/bug_test.rb +6 -0
  61. data/test/duplicate_names_test.rb +2 -2
  62. data/test/dynamic_method_test.rb +61 -0
  63. data/test/enumerable_test.rb +2 -2
  64. data/test/exceptions_test.rb +4 -3
  65. data/test/exclude_threads_test.rb +2 -2
  66. data/test/exec_test.rb +3 -3
  67. data/test/line_number_test.rb +5 -5
  68. data/test/measure_allocations_test.rb +25 -0
  69. data/test/measure_cpu_time_test.rb +212 -0
  70. data/test/measure_gc_runs_test.rb +29 -0
  71. data/test/measure_gc_time_test.rb +29 -0
  72. data/test/measure_memory_test.rb +36 -0
  73. data/test/measure_process_time_test.rb +205 -0
  74. data/test/measure_wall_time_test.rb +209 -0
  75. data/test/method_elimination_test.rb +2 -2
  76. data/test/module_test.rb +3 -2
  77. data/test/multi_printer_test.rb +2 -2
  78. data/test/no_method_class_test.rb +3 -1
  79. data/test/prime_test.rb +3 -3
  80. data/test/printers_test.rb +106 -8
  81. data/test/recursive_test.rb +7 -6
  82. data/test/singleton_test.rb +2 -2
  83. data/test/stack_printer_test.rb +2 -3
  84. data/test/stack_test.rb +2 -2
  85. data/test/start_stop_test.rb +2 -2
  86. data/test/test_helper.rb +81 -0
  87. data/test/test_suite.rb +34 -29
  88. data/test/thread_test.rb +24 -23
  89. data/test/unique_call_path_test.rb +2 -2
  90. metadata +101 -69
  91. data/ext/ruby_prof/measure_allocations.h +0 -83
  92. data/ext/ruby_prof/measure_cpu_time.h +0 -152
  93. data/ext/ruby_prof/measure_gc_runs.h +0 -76
  94. data/ext/ruby_prof/measure_gc_time.h +0 -57
  95. data/ext/ruby_prof/measure_memory.h +0 -101
  96. data/ext/ruby_prof/measure_process_time.h +0 -63
  97. data/ext/ruby_prof/measure_wall_time.h +0 -53
  98. data/ext/ruby_prof/mingw/Rakefile +0 -23
  99. data/ext/ruby_prof/mingw/build.rake +0 -38
  100. data/rails/environment/profile.rb +0 -24
  101. data/rails/example/example_test.rb +0 -9
  102. data/rails/profile_test_helper.rb +0 -21
  103. data/test/current_failures_windows +0 -8
  104. data/test/measurement_test.rb +0 -132
  105. data/test/ruby-prof-bin +0 -20
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # encoding: UTF-8
2
3
 
3
- require 'test/unit'
4
- require 'ruby-prof'
4
+ require File.expand_path('../test_helper', __FILE__)
5
5
 
6
6
  class UniqueCallPath
7
7
  def method_a(i)
metadata CHANGED
@@ -1,59 +1,54 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-prof
3
- version: !ruby/object:Gem::Version
4
- version: 0.10.8
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15424167
5
+ prerelease: 7
6
+ segments:
7
+ - 0
8
+ - 11
9
+ - 0
10
+ - rc
11
+ - 1
12
+ version: 0.11.0.rc1
6
13
  platform: ruby
7
- authors:
14
+ authors:
8
15
  - Shugo Maeda, Charlie Savage, Roger Pack, Stefan Kaes
9
16
  autorequire:
10
17
  bindir: bin
11
18
  cert_chain: []
12
- date: 2011-07-06 00:00:00.000000000 -06:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: os
17
- requirement: &20888076 !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
22
- version: '0'
23
- type: :development
24
- prerelease: false
25
- version_requirements: *20888076
26
- - !ruby/object:Gem::Dependency
19
+
20
+ date: 2012-03-24 00:00:00 Z
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
27
23
  name: rake-compiler
28
- requirement: &20887728 !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
29
26
  none: false
30
- requirements:
31
- - - ! '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
34
  type: :development
35
- prerelease: false
36
- version_requirements: *20887728
37
- description: ! 'ruby-prof is a fast code profiler for Ruby. It is a C extension and
38
-
35
+ version_requirements: *id001
36
+ description: |
37
+ ruby-prof is a fast code profiler for Ruby. It is a C extension and
39
38
  therefore is many times faster than the standard Ruby profiler. It
40
-
41
39
  supports both flat and graph profiles. For each method, graph profiles
42
-
43
40
  show how long the method ran, which methods called it and which
44
-
45
41
  methods it called. RubyProf generate both text and html and can output
46
-
47
42
  it to standard out or to a file.
48
43
 
49
- '
50
44
  email: shugo@ruby-lang.org, cfis@savagexi.com, rogerdpack@gmail.com, skaes@railsexpress.de
51
- executables:
45
+ executables:
52
46
  - ruby-prof
53
- extensions:
47
+ extensions:
54
48
  - ext/ruby_prof/extconf.rb
55
49
  extra_rdoc_files: []
56
- files:
50
+
51
+ files:
57
52
  - Rakefile
58
53
  - README.rdoc
59
54
  - LICENSE
@@ -72,23 +67,38 @@ files:
72
67
  - examples/multi.stack.html
73
68
  - examples/plus.png
74
69
  - examples/stack.html
70
+ - ext/ruby_prof/rp_call_info.c
71
+ - ext/ruby_prof/rp_measure.c
72
+ - ext/ruby_prof/rp_measure_allocations.c
73
+ - ext/ruby_prof/rp_measure_cpu_time.c
74
+ - ext/ruby_prof/rp_measure_gc_runs.c
75
+ - ext/ruby_prof/rp_measure_gc_time.c
76
+ - ext/ruby_prof/rp_measure_memory.c
77
+ - ext/ruby_prof/rp_measure_process_time.c
78
+ - ext/ruby_prof/rp_measure_wall_time.c
79
+ - ext/ruby_prof/rp_method.c
80
+ - ext/ruby_prof/rp_stack.c
81
+ - ext/ruby_prof/rp_thread.c
75
82
  - ext/ruby_prof/ruby_prof.c
76
- - ext/ruby_prof/measure_allocations.h
77
- - ext/ruby_prof/measure_cpu_time.h
78
- - ext/ruby_prof/measure_gc_runs.h
79
- - ext/ruby_prof/measure_gc_time.h
80
- - ext/ruby_prof/measure_memory.h
81
- - ext/ruby_prof/measure_process_time.h
82
- - ext/ruby_prof/measure_wall_time.h
83
+ - ext/ruby_prof/rp_call_info.h
84
+ - ext/ruby_prof/rp_measure.h
85
+ - ext/ruby_prof/rp_method.h
86
+ - ext/ruby_prof/rp_stack.h
87
+ - ext/ruby_prof/rp_thread.h
83
88
  - ext/ruby_prof/ruby_prof.h
84
89
  - ext/ruby_prof/version.h
85
- - ext/ruby_prof/mingw/Rakefile
86
- - ext/ruby_prof/mingw/build.rake
90
+ - lib/1.8/ruby_prof.so
91
+ - lib/1.9/ruby_prof.exp
92
+ - lib/1.9/ruby_prof.ilk
93
+ - lib/1.9/ruby_prof.lib
94
+ - lib/1.9/ruby_prof.pdb
95
+ - lib/1.9/ruby_prof.so
87
96
  - lib/ruby-prof/abstract_printer.rb
88
97
  - lib/ruby-prof/aggregate_call_info.rb
89
98
  - lib/ruby-prof/call_info.rb
90
99
  - lib/ruby-prof/call_stack_printer.rb
91
100
  - lib/ruby-prof/call_tree_printer.rb
101
+ - lib/ruby-prof/compatibility.rb
92
102
  - lib/ruby-prof/dot_printer.rb
93
103
  - lib/ruby-prof/empty.png
94
104
  - lib/ruby-prof/flat_printer.rb
@@ -99,27 +109,36 @@ files:
99
109
  - lib/ruby-prof/minus.png
100
110
  - lib/ruby-prof/multi_printer.rb
101
111
  - lib/ruby-prof/plus.png
112
+ - lib/ruby-prof/profile.rb
102
113
  - lib/ruby-prof/rack.rb
103
- - lib/ruby-prof/result.rb
104
114
  - lib/ruby-prof/symbol_to_proc.rb
105
115
  - lib/ruby-prof/task.rb
106
116
  - lib/ruby-prof/test.rb
107
117
  - lib/ruby-prof.rb
118
+ - lib/ruby_prof.exp
119
+ - lib/ruby_prof.ilk
120
+ - lib/ruby_prof.lib
121
+ - lib/ruby_prof.pdb
122
+ - lib/ruby_prof.so
108
123
  - lib/unprof.rb
109
- - rails/environment/profile.rb
110
- - rails/example/example_test.rb
111
- - rails/profile_test_helper.rb
112
124
  - test/aggregate_test.rb
113
125
  - test/basic_test.rb
114
- - test/current_failures_windows
126
+ - test/bug_test.rb
115
127
  - test/do_nothing.rb
116
128
  - test/duplicate_names_test.rb
129
+ - test/dynamic_method_test.rb
117
130
  - test/enumerable_test.rb
118
131
  - test/exceptions_test.rb
119
132
  - test/exclude_threads_test.rb
120
133
  - test/exec_test.rb
121
134
  - test/line_number_test.rb
122
- - test/measurement_test.rb
135
+ - test/measure_allocations_test.rb
136
+ - test/measure_cpu_time_test.rb
137
+ - test/measure_gc_runs_test.rb
138
+ - test/measure_gc_time_test.rb
139
+ - test/measure_memory_test.rb
140
+ - test/measure_process_time_test.rb
141
+ - test/measure_wall_time_test.rb
123
142
  - test/method_elimination_test.rb
124
143
  - test/module_test.rb
125
144
  - test/multi_printer_test.rb
@@ -128,39 +147,52 @@ files:
128
147
  - test/prime_test.rb
129
148
  - test/printers_test.rb
130
149
  - test/recursive_test.rb
131
- - test/ruby-prof-bin
132
150
  - test/singleton_test.rb
133
151
  - test/stack_printer_test.rb
134
152
  - test/stack_test.rb
135
153
  - test/start_stop_test.rb
154
+ - test/test_helper.rb
136
155
  - test/test_suite.rb
137
156
  - test/thread_test.rb
138
157
  - test/unique_call_path_test.rb
139
158
  - ext/ruby_prof/extconf.rb
140
- has_rdoc: true
141
- homepage: http://rubyforge.org/projects/ruby-prof/
159
+ homepage: https://github.com/rdp/ruby-prof
142
160
  licenses: []
161
+
143
162
  post_install_message:
144
163
  rdoc_options: []
145
- require_paths:
164
+
165
+ require_paths:
146
166
  - lib
147
- required_ruby_version: !ruby/object:Gem::Requirement
167
+ required_ruby_version: !ruby/object:Gem::Requirement
148
168
  none: false
149
- requirements:
150
- - - ! '>='
151
- - !ruby/object:Gem::Version
152
- version: 1.8.4
153
- required_rubygems_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ hash: 57
173
+ segments:
174
+ - 1
175
+ - 8
176
+ - 7
177
+ version: 1.8.7
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
179
  none: false
155
- requirements:
156
- - - ! '>='
157
- - !ruby/object:Gem::Version
158
- version: '0'
180
+ requirements:
181
+ - - ">"
182
+ - !ruby/object:Gem::Version
183
+ hash: 25
184
+ segments:
185
+ - 1
186
+ - 3
187
+ - 1
188
+ version: 1.3.1
159
189
  requirements: []
160
- rubyforge_project: ruby-prof
161
- rubygems_version: 1.5.2
190
+
191
+ rubyforge_project:
192
+ rubygems_version: 1.8.10
162
193
  signing_key:
163
194
  specification_version: 3
164
195
  summary: Fast Ruby profiler
165
- test_files:
196
+ test_files:
197
+ - test/test_helper.rb
166
198
  - test/test_suite.rb
@@ -1,83 +0,0 @@
1
- /* :nodoc:
2
- * Copyright (C) 2008 Shugo Maeda <shugo@ruby-lang.org>
3
- * Charlie Savage <cfis@savagexi.com>
4
- * All rights reserved.
5
- *
6
- * Redistribution and use in source and binary forms, with or without
7
- * modification, are permitted provided that the following conditions
8
- * are met:
9
- * 1. Redistributions of source code must retain the above copyright
10
- * notice, this list of conditions and the following disclaimer.
11
- * 2. Redistributions in binary form must reproduce the above copyright
12
- * notice, this list of conditions and the following disclaimer in the
13
- * documentation and/or other materials provided with the distribution.
14
- *
15
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
16
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
19
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25
- * SUCH DAMAGE. */
26
-
27
- #include <ruby.h>
28
-
29
- #if defined(HAVE_RB_OS_ALLOCATED_OBJECTS)
30
- #define MEASURE_ALLOCATIONS 3
31
-
32
- static prof_measure_t
33
- measure_allocations()
34
- {
35
- return rb_os_allocated_objects();
36
- }
37
-
38
- static double
39
- convert_allocations(prof_measure_t c)
40
- {
41
- return c;
42
- }
43
-
44
- /* Document-method: prof_measure_allocations
45
- call-seq:
46
- measure_allocations -> int
47
-
48
- Returns the total number of object allocations since Ruby started.*/
49
- static VALUE
50
- prof_measure_allocations(VALUE self)
51
- {
52
- #if defined(HAVE_LONG_LONG)
53
- return ULL2NUM(rb_os_allocated_objects());
54
- #else
55
- return ULONG2NUM(rb_os_allocated_objects());
56
- #endif
57
- }
58
-
59
- #elif defined(HAVE_RB_GC_MALLOC_ALLOCATIONS)
60
- #define MEASURE_ALLOCATIONS 3
61
-
62
- static prof_measure_t
63
- measure_allocations()
64
- {
65
- return rb_gc_malloc_allocations();
66
- }
67
-
68
- static double
69
- convert_allocations(prof_measure_t c)
70
- {
71
- return c;
72
- }
73
-
74
- static VALUE
75
- prof_measure_allocations(VALUE self)
76
- {
77
- #if defined(HAVE_LONG_LONG)
78
- return ULL2NUM(rb_os_allocated_objects());
79
- #else
80
- return ULONG2NUM(rb_os_allocated_objects());
81
- #endif
82
- }
83
- #endif
@@ -1,152 +0,0 @@
1
- /* :nodoc:
2
- * Copyright (C) 2008 Shugo Maeda <shugo@ruby-lang.org>
3
- * Charlie Savage <cfis@savagexi.com>
4
- * All rights reserved.
5
- *
6
- * Redistribution and use in source and binary forms, with or without
7
- * modification, are permitted provided that the following conditions
8
- * are met:
9
- * 1. Redistributions of source code must retain the above copyright
10
- * notice, this list of conditions and the following disclaimer.
11
- * 2. Redistributions in binary form must reproduce the above copyright
12
- * notice, this list of conditions and the following disclaimer in the
13
- * documentation and/or other materials provided with the distribution.
14
- *
15
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
16
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
19
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25
- * SUCH DAMAGE. */
26
-
27
- #include <ruby.h>
28
-
29
- #if defined(_WIN32) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__ppc__)))
30
- #define MEASURE_CPU_TIME 2
31
-
32
- static unsigned LONG_LONG cpu_frequency;
33
-
34
- #if defined(__GNUC__)
35
-
36
- #include <stdint.h>
37
-
38
- static prof_measure_t
39
- measure_cpu_time()
40
- {
41
- #if defined(__i386__) || defined(__x86_64__)
42
- uint32_t a, d;
43
- __asm__ volatile("rdtsc" : "=a" (a), "=d" (d));
44
- return ((uint64_t)d << 32) + a;
45
- #elif defined(__powerpc__) || defined(__ppc__)
46
- unsigned long long x, y;
47
-
48
- __asm__ __volatile__ ("\n\
49
- 1: mftbu %1\n\
50
- mftb %L0\n\
51
- mftbu %0\n\
52
- cmpw %0,%1\n\
53
- bne- 1b"
54
- : "=r" (x), "=r" (y));
55
- return x;
56
- #endif
57
- }
58
-
59
- #elif defined(_WIN32)
60
-
61
- static prof_measure_t
62
- measure_cpu_time()
63
- {
64
- prof_measure_t cycles = 0;
65
-
66
- __asm
67
- {
68
- rdtsc
69
- mov DWORD PTR cycles, eax
70
- mov DWORD PTR [cycles + 4], edx
71
- }
72
- return cycles;
73
- }
74
-
75
- #endif
76
-
77
-
78
- /* The _WIN32 check is needed for msys (and maybe cygwin?) */
79
- #if defined(__GNUC__) && !defined(_WIN32)
80
-
81
- unsigned long long get_cpu_frequency()
82
- {
83
- unsigned long long x, y;
84
-
85
- struct timespec ts;
86
- ts.tv_sec = 0;
87
- ts.tv_nsec = 500000000;
88
- x = measure_cpu_time();
89
- nanosleep(&ts, NULL);
90
- y = measure_cpu_time();
91
- return (y - x) * 2;
92
- }
93
-
94
- #elif defined(_WIN32)
95
-
96
- unsigned LONG_LONG get_cpu_frequency()
97
- {
98
- unsigned LONG_LONG x, y;
99
- unsigned LONG_LONG frequency;
100
- x = measure_cpu_time();
101
-
102
- /* Use the windows sleep function, not Ruby's */
103
- Sleep(500);
104
- y = measure_cpu_time();
105
- frequency = 2*(y-x);
106
- return frequency;
107
- }
108
- #endif
109
-
110
- static double
111
- convert_cpu_time(prof_measure_t c)
112
- {
113
- return (double) c / cpu_frequency;
114
- }
115
-
116
- /* Document-method: prof_measure_cpu_time
117
- call-seq:
118
- measure_cpu_time -> float
119
-
120
- Returns the cpu time.*/
121
- static VALUE
122
- prof_measure_cpu_time(VALUE self)
123
- {
124
- return rb_float_new(convert_cpu_time(measure_cpu_time()));
125
- }
126
-
127
- /* Document-method: prof_get_cpu_frequency
128
- call-seq:
129
- cpu_frequency -> int
130
-
131
- Returns the cpu's frequency. This value is needed when
132
- RubyProf::measure_mode is set to CPU_TIME. */
133
- static VALUE
134
- prof_get_cpu_frequency(VALUE self)
135
- {
136
- return ULL2NUM(cpu_frequency);
137
- }
138
-
139
- /* Document-method: prof_set_cpu_frequency
140
- call-seq:
141
- cpu_frequency=value -> void
142
-
143
- Sets the cpu's frequency. This value is needed when
144
- RubyProf::measure_mode is set to CPU_TIME. */
145
- static VALUE
146
- prof_set_cpu_frequency(VALUE self, VALUE val)
147
- {
148
- cpu_frequency = NUM2LL(val);
149
- return val;
150
- }
151
-
152
- #endif