airbnb-ruby-prof 0.0.1

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.
Files changed (116) hide show
  1. data/CHANGES +483 -0
  2. data/LICENSE +25 -0
  3. data/README.rdoc +426 -0
  4. data/Rakefile +51 -0
  5. data/bin/ruby-prof +279 -0
  6. data/bin/ruby-prof-check-trace +45 -0
  7. data/examples/flat.txt +50 -0
  8. data/examples/graph.dot +84 -0
  9. data/examples/graph.html +823 -0
  10. data/examples/graph.txt +139 -0
  11. data/examples/multi.flat.txt +23 -0
  12. data/examples/multi.graph.html +760 -0
  13. data/examples/multi.grind.dat +114 -0
  14. data/examples/multi.stack.html +547 -0
  15. data/examples/stack.html +547 -0
  16. data/ext/ruby_prof/extconf.rb +67 -0
  17. data/ext/ruby_prof/rp_call_info.c +374 -0
  18. data/ext/ruby_prof/rp_call_info.h +59 -0
  19. data/ext/ruby_prof/rp_fast_call_tree_printer.c +247 -0
  20. data/ext/ruby_prof/rp_fast_call_tree_printer.h +10 -0
  21. data/ext/ruby_prof/rp_measure.c +71 -0
  22. data/ext/ruby_prof/rp_measure.h +56 -0
  23. data/ext/ruby_prof/rp_measure_allocations.c +74 -0
  24. data/ext/ruby_prof/rp_measure_cpu_time.c +134 -0
  25. data/ext/ruby_prof/rp_measure_gc_runs.c +71 -0
  26. data/ext/ruby_prof/rp_measure_gc_time.c +58 -0
  27. data/ext/ruby_prof/rp_measure_memory.c +75 -0
  28. data/ext/ruby_prof/rp_measure_process_time.c +69 -0
  29. data/ext/ruby_prof/rp_measure_wall_time.c +43 -0
  30. data/ext/ruby_prof/rp_method.c +717 -0
  31. data/ext/ruby_prof/rp_method.h +79 -0
  32. data/ext/ruby_prof/rp_stack.c +221 -0
  33. data/ext/ruby_prof/rp_stack.h +81 -0
  34. data/ext/ruby_prof/rp_thread.c +312 -0
  35. data/ext/ruby_prof/rp_thread.h +36 -0
  36. data/ext/ruby_prof/ruby_prof.c +800 -0
  37. data/ext/ruby_prof/ruby_prof.h +64 -0
  38. data/ext/ruby_prof/vc/ruby_prof.sln +32 -0
  39. data/ext/ruby_prof/vc/ruby_prof_18.vcxproj +108 -0
  40. data/ext/ruby_prof/vc/ruby_prof_19.vcxproj +110 -0
  41. data/ext/ruby_prof/vc/ruby_prof_20.vcxproj +110 -0
  42. data/lib/ruby-prof.rb +63 -0
  43. data/lib/ruby-prof/aggregate_call_info.rb +76 -0
  44. data/lib/ruby-prof/assets/call_stack_printer.css.html +117 -0
  45. data/lib/ruby-prof/assets/call_stack_printer.js.html +385 -0
  46. data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
  47. data/lib/ruby-prof/assets/flame_graph_printer.lib.css.html +149 -0
  48. data/lib/ruby-prof/assets/flame_graph_printer.lib.js.html +707 -0
  49. data/lib/ruby-prof/assets/flame_graph_printer.page.js.html +56 -0
  50. data/lib/ruby-prof/assets/flame_graph_printer.tmpl.html.erb +39 -0
  51. data/lib/ruby-prof/call_info.rb +111 -0
  52. data/lib/ruby-prof/call_info_visitor.rb +40 -0
  53. data/lib/ruby-prof/compatibility.rb +186 -0
  54. data/lib/ruby-prof/method_info.rb +109 -0
  55. data/lib/ruby-prof/printers/abstract_printer.rb +85 -0
  56. data/lib/ruby-prof/printers/call_info_printer.rb +41 -0
  57. data/lib/ruby-prof/printers/call_stack_printer.rb +260 -0
  58. data/lib/ruby-prof/printers/call_tree_printer.rb +130 -0
  59. data/lib/ruby-prof/printers/dot_printer.rb +132 -0
  60. data/lib/ruby-prof/printers/fast_call_tree_printer.rb +87 -0
  61. data/lib/ruby-prof/printers/flame_graph_html_printer.rb +59 -0
  62. data/lib/ruby-prof/printers/flame_graph_json_printer.rb +157 -0
  63. data/lib/ruby-prof/printers/flat_printer.rb +70 -0
  64. data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +64 -0
  65. data/lib/ruby-prof/printers/graph_html_printer.rb +244 -0
  66. data/lib/ruby-prof/printers/graph_printer.rb +116 -0
  67. data/lib/ruby-prof/printers/multi_printer.rb +58 -0
  68. data/lib/ruby-prof/profile.rb +22 -0
  69. data/lib/ruby-prof/profile/exclude_common_methods.rb +201 -0
  70. data/lib/ruby-prof/rack.rb +95 -0
  71. data/lib/ruby-prof/task.rb +147 -0
  72. data/lib/ruby-prof/thread.rb +35 -0
  73. data/lib/ruby-prof/version.rb +4 -0
  74. data/lib/ruby-prof/walker.rb +95 -0
  75. data/lib/unprof.rb +10 -0
  76. data/ruby-prof.gemspec +56 -0
  77. data/test/aggregate_test.rb +136 -0
  78. data/test/basic_test.rb +128 -0
  79. data/test/block_test.rb +74 -0
  80. data/test/call_info_test.rb +78 -0
  81. data/test/call_info_visitor_test.rb +31 -0
  82. data/test/duplicate_names_test.rb +32 -0
  83. data/test/dynamic_method_test.rb +55 -0
  84. data/test/enumerable_test.rb +21 -0
  85. data/test/exceptions_test.rb +16 -0
  86. data/test/exclude_methods_test.rb +146 -0
  87. data/test/exclude_threads_test.rb +53 -0
  88. data/test/fiber_test.rb +79 -0
  89. data/test/issue137_test.rb +63 -0
  90. data/test/line_number_test.rb +71 -0
  91. data/test/measure_allocations_test.rb +26 -0
  92. data/test/measure_cpu_time_test.rb +213 -0
  93. data/test/measure_gc_runs_test.rb +32 -0
  94. data/test/measure_gc_time_test.rb +36 -0
  95. data/test/measure_memory_test.rb +33 -0
  96. data/test/measure_process_time_test.rb +63 -0
  97. data/test/measure_wall_time_test.rb +255 -0
  98. data/test/module_test.rb +45 -0
  99. data/test/multi_measure_test.rb +38 -0
  100. data/test/multi_printer_test.rb +83 -0
  101. data/test/no_method_class_test.rb +15 -0
  102. data/test/pause_resume_test.rb +166 -0
  103. data/test/prime.rb +54 -0
  104. data/test/printers_test.rb +255 -0
  105. data/test/printing_recursive_graph_test.rb +127 -0
  106. data/test/rack_test.rb +93 -0
  107. data/test/recursive_test.rb +212 -0
  108. data/test/singleton_test.rb +38 -0
  109. data/test/stack_printer_test.rb +65 -0
  110. data/test/stack_test.rb +138 -0
  111. data/test/start_stop_test.rb +112 -0
  112. data/test/test_helper.rb +264 -0
  113. data/test/thread_test.rb +187 -0
  114. data/test/unique_call_path_test.rb +202 -0
  115. data/test/yarv_test.rb +55 -0
  116. metadata +211 -0
@@ -0,0 +1,134 @@
1
+ /* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
+ Please see the LICENSE file for copyright and distribution information */
3
+
4
+ #include "ruby_prof.h"
5
+
6
+ static VALUE cMeasureCpuTime;
7
+
8
+ /* The _WIN32 check is needed for msys (and maybe cygwin?) */
9
+ #if defined(_WIN32)
10
+
11
+ static unsigned long long get_cpu_time()
12
+ {
13
+ LARGE_INTEGER time;
14
+ QueryPerformanceCounter(&time);
15
+ return time.QuadPart;
16
+ }
17
+
18
+ static unsigned long long get_cpu_frequency()
19
+ {
20
+ static unsigned long long cpu_frequency;
21
+
22
+ if(!cpu_frequency) {
23
+ LARGE_INTEGER cpu_frequency_struct;
24
+ QueryPerformanceFrequency(&cpu_frequency_struct);
25
+ cpu_frequency = cpu_frequency_struct.QuadPart;
26
+ }
27
+
28
+ return cpu_frequency;
29
+ }
30
+
31
+ static double measure_cpu_time()
32
+ {
33
+ return ((double)get_cpu_time()) / get_cpu_frequency();
34
+ }
35
+
36
+ #else
37
+
38
+ #include <sys/resource.h>
39
+ #include <stdint.h>
40
+ #include <time.h>
41
+
42
+ static unsigned long long get_cpu_time()
43
+ {
44
+ #if defined(__i386__) || defined(__x86_64__)
45
+ uint32_t a, d;
46
+ __asm__ volatile("rdtsc" : "=a" (a), "=d" (d));
47
+ return ((uint64_t)d << 32) + a;
48
+ #elif defined(__powerpc__) || defined(__ppc__)
49
+ unsigned long long x, y;
50
+
51
+ __asm__ __volatile__ ("\n\
52
+ 1: mftbu %1\n\
53
+ mftb %L0\n\
54
+ mftbu %0\n\
55
+ cmpw %0,%1\n\
56
+ bne- 1b"
57
+ : "=r" (x), "=r" (y));
58
+
59
+ return x;
60
+ #endif
61
+ }
62
+
63
+ static unsigned long long get_cpu_frequency()
64
+ {
65
+ static unsigned long long cpu_frequency;
66
+
67
+ if(!cpu_frequency) {
68
+ unsigned long long x, y;
69
+
70
+ struct timespec ts;
71
+ ts.tv_sec = 0;
72
+ ts.tv_nsec = 500000000;
73
+ x = get_cpu_time();
74
+ nanosleep(&ts, NULL);
75
+ y = get_cpu_time();
76
+ cpu_frequency = (y - x) * 2;
77
+ }
78
+
79
+ return cpu_frequency;
80
+ }
81
+
82
+ static double measure_cpu_time()
83
+ {
84
+ struct rusage rusage;
85
+ getrusage(RUSAGE_SELF, &rusage);
86
+
87
+ double seconds = 0;
88
+
89
+ seconds += rusage.ru_utime.tv_sec;
90
+ seconds += rusage.ru_stime.tv_sec;
91
+
92
+ seconds += rusage.ru_utime.tv_usec / 1000000.0;
93
+ seconds += rusage.ru_stime.tv_usec / 1000000.0;
94
+
95
+ return seconds;
96
+ }
97
+ #endif
98
+
99
+
100
+ get_measurement prof_measurer_cpu_time()
101
+ {
102
+ return measure_cpu_time;
103
+ }
104
+
105
+ /* call-seq:
106
+ measure -> float
107
+
108
+ Returns the cpu time.*/
109
+ static VALUE
110
+ prof_measure_cpu_time(VALUE self)
111
+ {
112
+ return rb_float_new(measure_cpu_time());
113
+ }
114
+
115
+ /* call-seq:
116
+ cpu_frequency -> int
117
+
118
+ Returns the cpu's frequency. This value is needed when
119
+ RubyProf::measure_mode is set to CPU_TIME. */
120
+ static VALUE
121
+ prof_get_cpu_frequency(VALUE self)
122
+ {
123
+ return ULL2NUM(get_cpu_frequency());
124
+ }
125
+
126
+ void rp_init_measure_cpu_time()
127
+ {
128
+ rb_define_const(mProf, "CPU_TIME", INT2NUM(MEASURE_CPU_TIME));
129
+ rb_define_const(mProf, "CPU_TIME_ENABLED", Qtrue);
130
+
131
+ cMeasureCpuTime = rb_define_class_under(mMeasure, "CpuTime", rb_cObject);
132
+ rb_define_singleton_method(cMeasureCpuTime, "measure", prof_measure_cpu_time, 0);
133
+ rb_define_singleton_method(cMeasureCpuTime, "frequency", prof_get_cpu_frequency, 0);
134
+ }
@@ -0,0 +1,71 @@
1
+ /* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
+ Please see the LICENSE file for copyright and distribution information */
3
+
4
+ /* :nodoc: */
5
+
6
+ #include "ruby_prof.h"
7
+
8
+ static VALUE cMeasureGcRuns;
9
+
10
+ #if defined(HAVE_RB_GC_COLLECTIONS)
11
+ VALUE rb_gc_collections(void);
12
+ #endif
13
+
14
+ #if defined(HAVE_RB_GC_COUNT)
15
+ size_t rb_gc_count(void);
16
+ #endif
17
+
18
+ #if defined(HAVE_RB_GC_HEAP_INFO)
19
+ VALUE rb_gc_heap_info(void);
20
+ #endif
21
+
22
+
23
+ static double
24
+ measure_gc_runs()
25
+ {
26
+ #if defined(HAVE_RB_GC_COLLECTIONS)
27
+ #define MEASURE_GC_RUNS_ENABLED Qtrue
28
+ return NUM2INT(rb_gc_collections());
29
+
30
+ #elif defined(HAVE_RB_GC_COUNT)
31
+ #define MEASURE_GC_RUNS_ENABLED Qtrue
32
+ return rb_gc_count();
33
+
34
+ #elif defined(HAVE_RB_GC_HEAP_INFO)
35
+ #define MEASURE_GC_RUNS_ENABLED Qtrue
36
+ VALUE h = rb_gc_heap_info();
37
+ return NUM2UINT(rb_hash_aref(h, rb_str_new2("num_gc_passes")));
38
+
39
+ #else
40
+ #define MEASURE_GC_RUNS_ENABLED Qfalse
41
+ return 0;
42
+ #endif
43
+ }
44
+
45
+ get_measurement prof_measurer_gc_runs()
46
+ {
47
+ return measure_gc_runs;
48
+ }
49
+
50
+ /* call-seq:
51
+ measure -> int
52
+
53
+ Returns the number of GC runs.*/
54
+ static VALUE
55
+ prof_measure_gc_runs(VALUE self)
56
+ {
57
+ #if defined(HAVE_LONG_LONG)
58
+ return ULL2NUM(measure_gc_runs());
59
+ #else
60
+ return ULONG2NUM(measure_gc_runs());
61
+ #endif
62
+ }
63
+
64
+ void rp_init_measure_gc_runs()
65
+ {
66
+ rb_define_const(mProf, "GC_RUNS", INT2NUM(MEASURE_GC_RUNS));
67
+ rb_define_const(mProf, "GC_RUNS_ENABLED", MEASURE_GC_RUNS_ENABLED);
68
+
69
+ cMeasureGcRuns = rb_define_class_under(mMeasure, "GcRuns", rb_cObject);
70
+ rb_define_singleton_method(cMeasureGcRuns, "measure", prof_measure_gc_runs, 0);
71
+ }
@@ -0,0 +1,58 @@
1
+ /* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
+ Please see the LICENSE file for copyright and distribution information */
3
+
4
+ /* :nodoc: */
5
+
6
+ #include "ruby_prof.h"
7
+
8
+ static VALUE cMeasureGcTimes;
9
+
10
+ #if defined(HAVE_RB_GC_TIME)
11
+ VALUE rb_gc_time();
12
+ #endif
13
+
14
+ static double
15
+ measure_gc_time()
16
+ {
17
+ #if defined(HAVE_RB_GC_TOTAL_TIME)
18
+ #define MEASURE_GC_TIME_ENABLED Qtrue
19
+ return rb_gc_total_time();
20
+
21
+ #elif defined(HAVE_RB_GC_TIME)
22
+ #define MEASURE_GC_TIME_ENABLED Qtrue
23
+ const double conversion = 1000000.0;
24
+ #if HAVE_LONG_LONG
25
+ return NUM2LL(rb_gc_time()) / conversion;
26
+ #else
27
+ return NUM2LONG(rb_gc_time()) / conversion;
28
+ #endif
29
+
30
+ #else
31
+ #define MEASURE_GC_TIME_ENABLED Qfalse
32
+ return 0.0;
33
+ #endif
34
+ }
35
+
36
+ get_measurement prof_measurer_gc_time()
37
+ {
38
+ return measure_gc_time;
39
+ }
40
+
41
+ /* call-seq:
42
+ measure -> float
43
+
44
+ Returns the time spent performing GC.*/
45
+ static VALUE
46
+ prof_measure_gc_time(VALUE self)
47
+ {
48
+ return rb_float_new(measure_gc_time());
49
+ }
50
+
51
+ void rp_init_measure_gc_time()
52
+ {
53
+ rb_define_const(mProf, "GC_TIME", INT2NUM(MEASURE_GC_TIME));
54
+ rb_define_const(mProf, "GC_TIME_ENABLED", MEASURE_GC_TIME_ENABLED);
55
+
56
+ cMeasureGcTimes = rb_define_class_under(mMeasure, "GcTime", rb_cObject);
57
+ rb_define_singleton_method(cMeasureGcTimes, "measure", prof_measure_gc_time, 0);
58
+ }
@@ -0,0 +1,75 @@
1
+ /* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
+ Please see the LICENSE file for copyright and distribution information */
3
+
4
+ /* :nodoc: */
5
+
6
+ #include "ruby_prof.h"
7
+
8
+ static VALUE cMeasureMemory;
9
+
10
+
11
+ #if defined(HAVE_RB_GC_ALLOCATED_SIZE)
12
+ VALUE rb_gc_allocated_size();
13
+ #endif
14
+
15
+ #if defined(HAVE_RB_GC_MALLOC_ALLOCATED_SIZE)
16
+ size_t rb_gc_malloc_allocated_size();
17
+ #endif
18
+
19
+ #if defined(HAVE_RB_HEAP_TOTAL_MEM)
20
+ //FIXME: did not find the patch to check prototype, assuming it to return size_t
21
+ size_t rb_heap_total_mem();
22
+ #endif
23
+
24
+ static double
25
+ measure_memory()
26
+ {
27
+ #if defined(HAVE_RB_GC_ALLOCATED_SIZE)
28
+ #define MEASURE_MEMORY_ENABLED Qtrue
29
+ #if defined(HAVE_LONG_LONG)
30
+ return NUM2LL(rb_gc_allocated_size()) / 1024.0;
31
+ #else
32
+ return NUM2ULONG(rb_gc_allocated_size()) / 1024.0;
33
+ #endif
34
+
35
+ #elif defined(HAVE_RB_GC_MALLOC_ALLOCATED_SIZE)
36
+ #define MEASURE_MEMORY_ENABLED Qtrue
37
+ return rb_gc_malloc_allocated_size() / 1024.0;
38
+
39
+ #elif defined(HAVE_RB_GC_TOTAL_MALLOCED_BYTES)
40
+ #define MEASURE_MEMORY_ENABLED Qtrue
41
+ return rb_gc_total_malloced_bytes() / 1024.0;
42
+
43
+ #elif defined(HAVE_RB_HEAP_TOTAL_MEM)
44
+ #define MEASURE_MEMORY_ENABLED Qtrue
45
+ return rb_heap_total_mem() / 1024.0;
46
+
47
+ #else
48
+ #define MEASURE_MEMORY_ENABLED Qfalse
49
+ return 0;
50
+ #endif
51
+ }
52
+
53
+ get_measurement prof_measurer_memory()
54
+ {
55
+ return measure_memory;
56
+ }
57
+
58
+ /* call-seq:
59
+ measure_process_time -> float
60
+
61
+ Returns the process time.*/
62
+ static VALUE
63
+ prof_measure_memory(VALUE self)
64
+ {
65
+ return rb_float_new(measure_memory());
66
+ }
67
+
68
+ void rp_init_measure_memory()
69
+ {
70
+ rb_define_const(mProf, "MEMORY", INT2NUM(MEASURE_MEMORY));
71
+ rb_define_const(mProf, "MEMORY_ENABLED", MEASURE_MEMORY_ENABLED);
72
+
73
+ cMeasureMemory = rb_define_class_under(mMeasure, "Memory", rb_cObject);
74
+ rb_define_singleton_method(cMeasureMemory, "measure", prof_measure_memory, 0);
75
+ }
@@ -0,0 +1,69 @@
1
+ /* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
+ Please see the LICENSE file for copyright and distribution information */
3
+
4
+ #include "ruby_prof.h"
5
+ #include <time.h>
6
+
7
+ static VALUE cMeasureProcessTime;
8
+
9
+ static double
10
+ measure_process_time()
11
+ {
12
+ #if defined(__linux__)
13
+ struct timespec clock;
14
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID , &clock);
15
+ return clock.tv_sec + (clock.tv_nsec/1000000000.0);
16
+ #elif defined(_win32)
17
+ FILETIME createTime;
18
+ FILETIME exitTime;
19
+ FILETIME sysTime;
20
+ FILETIME cpuTime;
21
+
22
+ ULARGE_INTEGER sysTimeInt;
23
+ ULARGE_INTEGER cpuTimeInt;
24
+ ULONGLONG totalTime;
25
+
26
+ GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &sysTime, &cpuTime);
27
+
28
+ /* Doing this based on MSFT's recommendation in the FILETIME structure documentation at
29
+ http://msdn.microsoft.com/en-us/library/ms724284%28VS.85%29.aspx*/
30
+
31
+ sysTimeInt.LowPart = sysTime.dwLowDateTime;
32
+ sysTimeInt.HighPart = sysTime.dwHighDateTime;
33
+ cpuTimeInt.LowPart = cpuTime.dwLowDateTime;
34
+ cpuTimeInt.HighPart = cpuTime.dwHighDateTime;
35
+
36
+ totalTime = sysTimeInt.QuadPart + cpuTimeInt.QuadPart;
37
+
38
+ // Times are in 100-nanosecond time units. So instead of 10-9 use 10-7
39
+ return totalTime / 10000000.0;
40
+ #else
41
+ return ((double)clock()) / CLOCKS_PER_SEC;
42
+ #endif
43
+ }
44
+
45
+ /* call-seq:
46
+ measure_process_time -> float
47
+
48
+ Returns the process time.*/
49
+ static VALUE
50
+ prof_measure_process_time(VALUE self)
51
+ {
52
+ return rb_float_new(measure_process_time());
53
+ }
54
+
55
+ get_measurement prof_measurer_process_time()
56
+ {
57
+ return measure_process_time;
58
+ }
59
+
60
+
61
+ void rp_init_measure_process_time()
62
+ {
63
+ rb_define_const(mProf, "CLOCKS_PER_SEC", INT2NUM(CLOCKS_PER_SEC));
64
+ rb_define_const(mProf, "PROCESS_TIME", INT2NUM(MEASURE_PROCESS_TIME));
65
+ rb_define_const(mProf, "PROCESS_TIME_ENABLED", Qtrue);
66
+
67
+ cMeasureProcessTime = rb_define_class_under(mMeasure, "ProcessTime", rb_cObject);
68
+ rb_define_singleton_method(cMeasureProcessTime, "measure", prof_measure_process_time, 0);
69
+ }
@@ -0,0 +1,43 @@
1
+ /* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
+ Please see the LICENSE file for copyright and distribution information */
3
+
4
+ /* :nodoc: */
5
+ #include "ruby_prof.h"
6
+ #if HAVE_GETTIMEOFDAY && !defined(_WIN32)
7
+ #include <sys/time.h>
8
+ #endif
9
+
10
+ static VALUE cMeasureWallTime;
11
+
12
+ static double
13
+ measure_wall_time()
14
+ {
15
+ struct timeval tv;
16
+ gettimeofday(&tv, NULL);
17
+ return tv.tv_sec + (tv.tv_usec/1000000.0);
18
+ }
19
+
20
+ get_measurement prof_measurer_wall_time()
21
+ {
22
+ return measure_wall_time;
23
+ }
24
+
25
+ /* Document-method: prof_measure_wall_time
26
+ call-seq:
27
+ measure_wall_time -> float
28
+
29
+ Returns the wall time.*/
30
+ static VALUE
31
+ prof_measure_wall_time(VALUE self)
32
+ {
33
+ return rb_float_new(measure_wall_time());
34
+ }
35
+
36
+ void rp_init_measure_wall_time()
37
+ {
38
+ rb_define_const(mProf, "WALL_TIME", INT2NUM(MEASURE_WALL_TIME));
39
+ rb_define_const(mProf, "WALL_TIME_ENABLED", Qtrue);
40
+
41
+ cMeasureWallTime = rb_define_class_under(mMeasure, "WallTime", rb_cObject);
42
+ rb_define_singleton_method(cMeasureWallTime, "measure", prof_measure_wall_time, 0);
43
+ }