stella 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/README.textile +14 -10
  2. data/Rakefile +22 -36
  3. data/lib/daemonize.rb +56 -0
  4. data/lib/stella/adapter/ab.rb +49 -39
  5. data/lib/stella/adapter/base.rb +17 -8
  6. data/lib/stella/adapter/httperf.rb +24 -18
  7. data/lib/stella/adapter/pcap_watcher.rb +1 -1
  8. data/lib/stella/adapter/siege.rb +15 -12
  9. data/lib/stella/cli/localtest.rb +2 -3
  10. data/lib/stella/cli/sysinfo.rb +0 -1
  11. data/lib/stella/cli.rb +10 -55
  12. data/lib/stella/command/base.rb +0 -62
  13. data/lib/stella/command/localtest.rb +35 -36
  14. data/lib/stella/data/domain.rb +18 -11
  15. data/lib/stella/data/http.rb +23 -16
  16. data/lib/stella/logger.rb +29 -19
  17. data/lib/stella/response.rb +5 -2
  18. data/lib/stella/storable.rb +138 -52
  19. data/lib/stella/support.rb +107 -8
  20. data/lib/stella/sysinfo.rb +26 -16
  21. data/lib/stella/test/definition.rb +1 -1
  22. data/lib/stella/test/run/summary.rb +23 -13
  23. data/lib/stella/test/stats.rb +114 -0
  24. data/lib/stella/text/resource.rb +1 -1
  25. data/lib/stella.rb +29 -4
  26. data/lib/utils/mathutil.rb +0 -76
  27. data/lib/utils/stats.rb +88 -0
  28. data/lib/win32/Console/ANSI.rb +305 -305
  29. data/lib/win32/Console.rb +970 -970
  30. data/support/ruby-pcap-takuma-patch.txt +13 -13
  31. data/support/text/en.yaml +11 -8
  32. data/support/text/nl.yaml +7 -1
  33. data/{spec/show-agents_spec.rb → tests/01-util_test.rb} +0 -0
  34. data/tests/02-stella-util_test.rb +42 -0
  35. data/tests/10-stella_test.rb +104 -0
  36. data/tests/11-stella-storable_test.rb +68 -0
  37. data/tests/60-stella-command_test.rb +248 -0
  38. data/tests/80-stella-cli_test.rb +45 -0
  39. data/tests/spec-helper.rb +31 -0
  40. data/vendor/{frylock/README.textile → drydock/LICENSE.txt} +2 -52
  41. data/vendor/drydock/README.textile +57 -0
  42. data/vendor/{frylock → drydock}/bin/example +14 -14
  43. data/vendor/{frylock/frylock.gemspec → drydock/drydock.gemspec} +1 -1
  44. data/vendor/{frylock/lib/frylock → drydock/lib/drydock}/exceptions.rb +1 -1
  45. data/vendor/{frylock/lib/frylock.rb → drydock/lib/drydock.rb} +8 -8
  46. data/vendor/{frylock → drydock}/test/command_test.rb +0 -0
  47. metadata +34 -61
  48. data/lib/stella/test/base.rb +0 -38
  49. data/lib/stella/test/summary.rb +0 -82
  50. data/vendor/hitimes-0.4.0/HISTORY +0 -28
  51. data/vendor/hitimes-0.4.0/LICENSE.txt +0 -19
  52. data/vendor/hitimes-0.4.0/README +0 -80
  53. data/vendor/hitimes-0.4.0/Rakefile +0 -63
  54. data/vendor/hitimes-0.4.0/examples/benchmarks.rb +0 -86
  55. data/vendor/hitimes-0.4.0/examples/stats.rb +0 -29
  56. data/vendor/hitimes-0.4.0/ext/extconf.rb +0 -15
  57. data/vendor/hitimes-0.4.0/ext/hitimes_ext.c +0 -21
  58. data/vendor/hitimes-0.4.0/ext/hitimes_instant_clock_gettime.c +0 -20
  59. data/vendor/hitimes-0.4.0/ext/hitimes_instant_osx.c +0 -16
  60. data/vendor/hitimes-0.4.0/ext/hitimes_instant_windows.c +0 -27
  61. data/vendor/hitimes-0.4.0/ext/hitimes_interval.c +0 -340
  62. data/vendor/hitimes-0.4.0/ext/hitimes_interval.h +0 -73
  63. data/vendor/hitimes-0.4.0/ext/hitimes_stats.c +0 -242
  64. data/vendor/hitimes-0.4.0/ext/hitimes_stats.h +0 -30
  65. data/vendor/hitimes-0.4.0/ext/rbconfig-mingw.rb +0 -178
  66. data/vendor/hitimes-0.4.0/ext/rbconfig.rb +0 -178
  67. data/vendor/hitimes-0.4.0/gemspec.rb +0 -54
  68. data/vendor/hitimes-0.4.0/lib/hitimes/mutexed_stats.rb +0 -23
  69. data/vendor/hitimes-0.4.0/lib/hitimes/paths.rb +0 -54
  70. data/vendor/hitimes-0.4.0/lib/hitimes/stats.rb +0 -29
  71. data/vendor/hitimes-0.4.0/lib/hitimes/timer.rb +0 -223
  72. data/vendor/hitimes-0.4.0/lib/hitimes/version.rb +0 -42
  73. data/vendor/hitimes-0.4.0/lib/hitimes.rb +0 -24
  74. data/vendor/hitimes-0.4.0/spec/interval_spec.rb +0 -115
  75. data/vendor/hitimes-0.4.0/spec/mutex_stats_spec.rb +0 -34
  76. data/vendor/hitimes-0.4.0/spec/paths_spec.rb +0 -14
  77. data/vendor/hitimes-0.4.0/spec/spec_helper.rb +0 -6
  78. data/vendor/hitimes-0.4.0/spec/stats_spec.rb +0 -72
  79. data/vendor/hitimes-0.4.0/spec/timer_spec.rb +0 -105
  80. data/vendor/hitimes-0.4.0/spec/version_spec.rb +0 -27
  81. data/vendor/hitimes-0.4.0/tasks/announce.rake +0 -39
  82. data/vendor/hitimes-0.4.0/tasks/config.rb +0 -107
  83. data/vendor/hitimes-0.4.0/tasks/distribution.rake +0 -53
  84. data/vendor/hitimes-0.4.0/tasks/documentation.rake +0 -33
  85. data/vendor/hitimes-0.4.0/tasks/extension.rake +0 -64
  86. data/vendor/hitimes-0.4.0/tasks/rspec.rake +0 -31
  87. data/vendor/hitimes-0.4.0/tasks/rubyforge.rake +0 -52
  88. data/vendor/hitimes-0.4.0/tasks/utils.rb +0 -80
@@ -1,86 +0,0 @@
1
- require 'benchmark'
2
- require 'time'
3
-
4
- #
5
- # this is all here in case this example is run from the examples directory
6
- #
7
- begin
8
- require 'hitimes'
9
- rescue LoadError => le
10
- ext_path = File.expand_path( File.join( File.dirname( __FILE__ ), "..", "ext" ) )
11
- lib_path = File.expand_path( File.join( File.dirname( __FILE__ ), "..", "lib" ) )
12
- if $:.include?( ext_path ) then
13
- raise le
14
- end
15
- $: << ext_path
16
- $: << lib_path
17
- retry
18
- end
19
-
20
- #----------------------------------------------------------------------
21
- # test program to look at the performance sampling time durations using
22
- # different methods
23
- #----------------------------------------------------------------------
24
-
25
- include Benchmark
26
-
27
- #
28
- # Normal apprach to Interval usage
29
- #
30
- def hitimes_duration_i1
31
- i = Hitimes::Interval.new
32
- i.start
33
- i.stop
34
- end
35
-
36
- #
37
- # Use the easy access method to start stop an interval
38
- #
39
- def hitimes_duration_i2
40
- Hitimes::Interval.now.stop
41
- end
42
-
43
- #
44
- # Use a new timer each time
45
- #
46
- def hitimes_duration_t1
47
- Hitimes::Timer.now.stop
48
- end
49
-
50
- #
51
- # reuse the same timer over and over
52
- #
53
- HT = Hitimes::Timer.new
54
- def hitimes_duration_t2
55
- HT.start
56
- HT.stop
57
- end
58
-
59
- #
60
- # use the Struct::Tms values and return the difference in User time between 2
61
- # successive calls
62
- #
63
- def process_duration
64
- t1 = Process.times.utime
65
- Process.times.utime - t1
66
- end
67
-
68
- #
69
- # Take 2 times and subtract one from the other
70
- #
71
- def time_duration
72
- t1 = Time.now.to_f
73
- Time.now.to_f - t1
74
- end
75
-
76
-
77
- puts "Testing time sampling 100,000 times"
78
-
79
- bm(20) do |x|
80
- x.report("Process") { 100_000.times { process_duration } }
81
- x.report("Time") { 100_000.times { time_duration } }
82
- x.report("Hitimes::Timer 1") { 100_000.times { hitimes_duration_t1 } }
83
- x.report("Hitimes::Timer 2") { 100_000.times { hitimes_duration_t2 } }
84
- x.report("Hitimes::Interval 1") { 100_000.times { hitimes_duration_i1 } }
85
- x.report("Hitimes::Interval 2") { 100_000.times { hitimes_duration_i2 } }
86
- end
@@ -1,29 +0,0 @@
1
- #
2
- # this is all here in case this example is run from the examples directory
3
- #
4
- begin
5
- require 'hitimes'
6
- rescue LoadError => le
7
- %w[ ext lib ].each do |p|
8
- path = File.expand_path( File.join( File.dirname( __FILE__ ), "..", p ) )
9
- if $:.include?( path ) then
10
- raise le
11
- end
12
- $: << path
13
- end
14
- retry
15
- end
16
-
17
- s = Hitimes::Stats.new
18
- dir = ARGV.shift || Dir.pwd
19
- Dir.entries( dir ).each do |entry|
20
- fs = File.stat( entry )
21
- if fs.file? then
22
- s.update( fs.size )
23
- end
24
- end
25
-
26
- %w[ count min max mean sum stddev ].each do |m|
27
- puts "#{m.rjust(6)} : #{s.send( m ) }"
28
- end
29
-
@@ -1,15 +0,0 @@
1
- require 'rbconfig'
2
- require 'mkmf'
3
-
4
- if Config::CONFIG['host_os'] =~ /darwin/ then
5
- $CFLAGS += " -DUSE_INSTANT_OSX=1 -Wall"
6
- $LDFLAGS += " -framework CoreServices"
7
- elsif Config::CONFIG['host_os'] =~ /win32/ or Config::CONFIG['host_os'] =~ /mingw/ then
8
- $CFLAGS += " -DUSE_INSTANT_WINDOWS=1"
9
- else
10
- if have_library("rt", "clock_gettime") then
11
- $CFLAGS += " -DUSE_INSTANT_CLOCK_GETTIME=1"
12
- end
13
- end
14
-
15
- create_makefile('hitimes_ext')
@@ -1,21 +0,0 @@
1
- #include <ruby.h>
2
- #include "hitimes_interval.h"
3
-
4
- /* Module and Classes */
5
- VALUE mH; /* module Hitimes */
6
- VALUE eH_Error; /* class Hitimes::Error */
7
-
8
- /*
9
- * Document-class: Hitimes::Error
10
- *
11
- * General error class for the Hitimes module
12
- */
13
- void Init_hitimes_ext( )
14
- {
15
- mH = rb_define_module("Hitimes");
16
-
17
- eH_Error = rb_define_class_under(mH, "Error", rb_eStandardError);
18
-
19
- Init_hitimes_interval();
20
- Init_hitimes_stats( );
21
- }
@@ -1,20 +0,0 @@
1
- #ifdef USE_INSTANT_CLOCK_GETTIME
2
-
3
- #include "hitimes_interval.h"
4
-
5
- #include <sys/time.h>
6
-
7
- hitimes_instant_t hitimes_get_current_instant( )
8
- {
9
- struct timespec time;
10
- int rc;
11
-
12
- rc = clock_gettime( CLOCK_MONOTONIC, &time);
13
- if ( 0 != rc ) {
14
- char* e = strerror( rc );
15
- rb_raise(eH_Error, "Unable to retrieve time for CLOCK_MONOTONIC : %s", e );
16
- }
17
-
18
- return ( ( NANOSECONDS_PER_SECOND * (long)time.tv_sec ) + time.tv_nsec );
19
- }
20
- #endif
@@ -1,16 +0,0 @@
1
- #ifdef USE_INSTANT_OSX
2
-
3
- #include "hitimes_interval.h"
4
- #include <CoreServices/CoreServices.h>
5
-
6
- /*
7
- * returns the number of nanoseconds since the machine was booted
8
- */
9
- hitimes_instant_t hitimes_get_current_instant( )
10
- {
11
- Nanoseconds nano = AbsoluteToNanoseconds( UpTime() );
12
-
13
- return *( hitimes_instant_t *)&nano;
14
- }
15
-
16
- #endif
@@ -1,27 +0,0 @@
1
- #ifdef USE_INSTANT_WINDOWS
2
-
3
- #include "hitimes_interval.h"
4
-
5
-
6
- /*
7
- * returns the conversion factor, this value is used to convert
8
- * the value from hitimes_get_current_instant() into seconds
9
- */
10
- double hitimes_instant_conversion_factor()
11
- {
12
- LARGE_INTEGER ticks_per_second;
13
- QueryPerformanceFrequency( &ticks_per_second );
14
- return (double)ticks_per_second.QuadPart;
15
- }
16
-
17
- /*
18
- * returns the number of ticks
19
- */
20
- hitimes_instant_t hitimes_get_current_instant()
21
- {
22
- LARGE_INTEGER tick;
23
- QueryPerformanceCounter(&tick);
24
- return (hitimes_instant_t)tick.QuadPart;
25
- }
26
-
27
- #endif
@@ -1,340 +0,0 @@
1
- /**
2
- * Copyright (c) 2008 Jeremy Hinegardner
3
- * All rights reserved. See LICENSE and/or COPYING for details.
4
- *
5
- * vim: shiftwidth=4
6
- */
7
-
8
- #include "hitimes_interval.h"
9
-
10
- /* Modules and Classes -- defined here */
11
- VALUE cH_Interval; /* class Hitimes::Interval */
12
-
13
- /**
14
- * Allocator and Deallocator for Interval classes
15
- */
16
-
17
- VALUE hitimes_interval_free(hitimes_interval_t* i)
18
- {
19
- if ( Qnil != i->duration ) {
20
- rb_gc_unregister_address( &(i->duration) );
21
- i->duration = Qnil;
22
- }
23
- xfree( i );
24
- return Qnil;
25
- }
26
-
27
- VALUE hitimes_interval_alloc(VALUE klass)
28
- {
29
- VALUE obj;
30
- hitimes_interval_t* i = xmalloc( sizeof( hitimes_interval_t ) );
31
-
32
- i->start_instant = 0L;
33
- i->stop_instant = 0L;
34
- i->duration = Qnil;
35
-
36
- obj = Data_Wrap_Struct(klass, NULL, hitimes_interval_free, i);
37
- return obj;
38
- }
39
-
40
- /**
41
- * call-seq:
42
- * Interval.now -> Interval
43
- *
44
- * Create an interval that has already started
45
- */
46
- VALUE hitimes_interval_now( VALUE self )
47
- {
48
- VALUE obj;
49
- hitimes_interval_t *i = xmalloc( sizeof( hitimes_interval_t ) );
50
-
51
- i->start_instant = hitimes_get_current_instant( );
52
- i->stop_instant = 0L;
53
- i->duration = Qnil;
54
-
55
- obj = Data_Wrap_Struct(cH_Interval, NULL, hitimes_interval_free, i);
56
-
57
- return obj;
58
- }
59
-
60
- /**
61
- * call-seq:
62
- * Interval.measure { } -> Float
63
- *
64
- * Times the execution of the block returning the number of seconds it took
65
- */
66
- VALUE hitimes_interval_measure( VALUE self )
67
- {
68
- hitimes_instant_t before;
69
- hitimes_instant_t after;
70
- double duration;
71
-
72
- if ( !rb_block_given_p() ) {
73
- rb_raise(eH_Error, "No block given to Interval.measure" );
74
- }
75
-
76
- before = hitimes_get_current_instant( );
77
- rb_yield( Qnil );
78
- after = hitimes_get_current_instant( );
79
-
80
- duration = ( after - before ) / HITIMES_INSTANT_CONVERSION_FACTOR;
81
- return rb_float_new( duration );
82
- }
83
-
84
- /**
85
- * call-seq:
86
- * interval.split -> Interval
87
- *
88
- * Immediately stop the current interval and start a new interval that has a
89
- * start_instant equivalent to the stop_interval of self.
90
- */
91
- VALUE hitimes_interval_split( VALUE self )
92
- {
93
- hitimes_interval_t *first;
94
- hitimes_interval_t *second = xmalloc( sizeof( hitimes_interval_t ) );
95
- VALUE obj;
96
-
97
- Data_Get_Struct( self, hitimes_interval_t, first );
98
- first->stop_instant = hitimes_get_current_instant( );
99
-
100
- second->start_instant = first->stop_instant;
101
- second->stop_instant = 0L;
102
- second->duration = Qnil;
103
-
104
- obj = Data_Wrap_Struct(cH_Interval, NULL, hitimes_interval_free, second);
105
-
106
- return obj;
107
- }
108
-
109
-
110
- /**
111
- * call-seq:
112
- * interval.start -> boolean
113
- *
114
- * mark the start of the interval. Calling start on an already started
115
- * interval has no effect. An interval can only be started once. If the
116
- * interval is truely started +true+ is returned otherwise +false+.
117
- */
118
- VALUE hitimes_interval_start( VALUE self )
119
- {
120
- hitimes_interval_t *i;
121
- VALUE rc = Qfalse;
122
-
123
- Data_Get_Struct( self, hitimes_interval_t, i );
124
- if ( 0L == i->start_instant ) {
125
- i->start_instant = hitimes_get_current_instant( );
126
- i->stop_instant = 0L;
127
- i->duration = Qnil;
128
-
129
- rc = Qtrue;
130
- }
131
-
132
- return rc;
133
- }
134
-
135
-
136
- /**
137
- * call-seq:
138
- * interval.stop -> bool or Float
139
- *
140
- * mark the stop of the interval. Calling stop on an already stopped interval
141
- * has no effect. An interval can only be stopped once. If the interval is
142
- * truely stopped then the duration is returned, otherwise +false+.
143
- */
144
- VALUE hitimes_interval_stop( VALUE self )
145
- {
146
- hitimes_interval_t *i;
147
- VALUE rc = Qfalse;
148
-
149
- Data_Get_Struct( self, hitimes_interval_t, i );
150
- if ( 0L == i->start_instant ) {
151
- rb_raise(eH_Error, "Attempt to stop an interval that has not started.\n" );
152
- }
153
-
154
- if ( 0L == i->stop_instant ) {
155
- double d;
156
-
157
- i->stop_instant = hitimes_get_current_instant( );
158
- d = ( i->stop_instant - i->start_instant ) / HITIMES_INSTANT_CONVERSION_FACTOR;
159
- i->duration = rb_float_new( d );
160
- rb_gc_register_address( &(i->duration) );
161
- rc = i->duration;
162
- }
163
-
164
- return rc;
165
- }
166
-
167
- /**
168
- * call-seq:
169
- * interval.started? -> boolean
170
- *
171
- * returns whether or not the interval has been started
172
- */
173
- VALUE hitimes_interval_started( VALUE self )
174
- {
175
- hitimes_interval_t *i;
176
-
177
- Data_Get_Struct( self, hitimes_interval_t, i );
178
-
179
- return ( 0L == i->start_instant ) ? Qfalse : Qtrue;
180
- }
181
-
182
-
183
- /**
184
- * call-seq:
185
- * interval.stopped? -> boolean
186
- *
187
- * returns whether or not the interval has been stopped
188
- */
189
- VALUE hitimes_interval_stopped( VALUE self )
190
- {
191
- hitimes_interval_t *i;
192
-
193
- Data_Get_Struct( self, hitimes_interval_t, i );
194
-
195
- return ( 0L == i->stop_instant ) ? Qfalse : Qtrue;
196
- }
197
-
198
- /**
199
- * call-seq:
200
- * interval.running? -> boolean
201
- *
202
- * returns whether or not the interval is running or not. This means that it
203
- * has started, but not stopped.
204
- */
205
- VALUE hitimes_interval_running( VALUE self )
206
- {
207
- hitimes_interval_t *i;
208
- VALUE rc = Qfalse;
209
-
210
- Data_Get_Struct( self, hitimes_interval_t, i );
211
- if ( ( 0L != i->start_instant ) && ( 0L == i->stop_instant ) ) {
212
- rc = Qtrue;
213
- }
214
-
215
- return rc;
216
- }
217
-
218
-
219
- /**
220
- * call-seq:
221
- * interval.start_instant -> Integer
222
- *
223
- * The integer representing the start instant of the Interval. This value
224
- * is not useful on its own. It is a platform dependent value.
225
- */
226
- VALUE hitimes_interval_start_instant( VALUE self )
227
- {
228
- hitimes_interval_t *i;
229
-
230
- Data_Get_Struct( self, hitimes_interval_t, i );
231
-
232
- return ULL2NUM( i->start_instant );
233
- }
234
-
235
-
236
- /**
237
- * call-seq:
238
- * interval.stop_instant -> Integer
239
- *
240
- * The integer representing the stop instant of the Interval. This value
241
- * is not useful on its own. It is a platform dependent value.
242
- */
243
- VALUE hitimes_interval_stop_instant( VALUE self )
244
- {
245
- hitimes_interval_t *i;
246
-
247
- Data_Get_Struct( self, hitimes_interval_t, i );
248
-
249
- return ULL2NUM( i->stop_instant );
250
- }
251
-
252
-
253
-
254
- /**
255
- * call-seq:
256
- * interval.duration -> Float
257
- *
258
- * Returns the Float value of the interval, the value is in seconds. If the
259
- * interval has not had stop called yet, it will report the number of seconds
260
- * in the interval up to the current point in time.
261
- */
262
- VALUE hitimes_interval_duration ( VALUE self )
263
- {
264
- hitimes_interval_t *i;
265
- double d;
266
-
267
- Data_Get_Struct( self, hitimes_interval_t, i );
268
-
269
- /**
270
- * if stop has not yet been called, then return the amount of time so far
271
- */
272
- if ( 0L == i->stop_instant ) {
273
- hitimes_instant_t now = hitimes_get_current_instant( );
274
- d = ( now - i->start_instant ) / HITIMES_INSTANT_CONVERSION_FACTOR;
275
- return rb_float_new( d );
276
- }
277
-
278
-
279
- /*
280
- * stop has been called, calculate the duration and save the result
281
- */
282
- if ( Qnil == i->duration ) {
283
- d = ( i->stop_instant - i->start_instant ) / HITIMES_INSTANT_CONVERSION_FACTOR;
284
- i->duration = rb_float_new( d );
285
- rb_gc_register_address( &(i->duration) );
286
- }
287
-
288
- return i->duration;
289
- }
290
-
291
-
292
- /**
293
- * Document-class: Hitimes::Interval
294
- *
295
- * This is the lowest level timing mechanism available. It allows for easy
296
- * measuring based upon a block:
297
- *
298
- * duration = Interval.measure { ... }
299
- *
300
- * Or measuring something specifically
301
- *
302
- * interval = Interval.new
303
- * interval.start
304
- * duration = interval.stop
305
- *
306
- * Allocating and starting an interval can be done in one method call with
307
- *
308
- * interval = Interval.now
309
- *
310
- * Interval is useful when you only need to track a single interval of time, or
311
- * if you do not want to track statistics about an operation.
312
- *
313
- */
314
- void Init_hitimes_interval()
315
- {
316
- mH = rb_define_module("Hitimes");
317
-
318
- cH_Interval = rb_define_class_under( mH, "Interval", rb_cObject );
319
- rb_define_alloc_func( cH_Interval, hitimes_interval_alloc );
320
-
321
- rb_define_module_function( cH_Interval, "now", hitimes_interval_now, 0 ); /* in hitimes_interval.c */
322
- rb_define_module_function( cH_Interval, "measure", hitimes_interval_measure, 0 ); /* in hitimes_interval.c */
323
-
324
- rb_define_method( cH_Interval, "to_f", hitimes_interval_duration, 0 ); /* in hitimes_interval.c */
325
- rb_define_method( cH_Interval, "to_seconds", hitimes_interval_duration, 0 ); /* in hitimes_interval.c */
326
- rb_define_method( cH_Interval, "duration", hitimes_interval_duration, 0 ); /* in hitimes_interval.c */
327
- rb_define_method( cH_Interval, "length", hitimes_interval_duration, 0 ); /* in hitimes_interval.c */
328
-
329
- rb_define_method( cH_Interval, "started?", hitimes_interval_started, 0 ); /* in hitimes_interval.c */
330
- rb_define_method( cH_Interval, "running?", hitimes_interval_running, 0 ); /* in hitimes_interval.c */
331
- rb_define_method( cH_Interval, "stopped?", hitimes_interval_stopped, 0 ); /* in hitimes_interval.c */
332
-
333
- rb_define_method( cH_Interval, "start_instant", hitimes_interval_start_instant, 0 ); /* in hitimes_interval.c */
334
- rb_define_method( cH_Interval, "stop_instant", hitimes_interval_stop_instant, 0 ); /* in hitimes_interval.c */
335
-
336
- rb_define_method( cH_Interval, "start", hitimes_interval_start, 0); /* in hitimes_interval.c */
337
- rb_define_method( cH_Interval, "stop", hitimes_interval_stop, 0); /* in hitimes_interval.c */
338
- rb_define_method( cH_Interval, "split", hitimes_interval_split, 0); /* in hitimes_interval.c */
339
-
340
- }
@@ -1,73 +0,0 @@
1
- /**
2
- * Copyright (c) 2008 Jeremy Hinegardner
3
- * All rights reserved. See LICENSE and/or COPYING for details.
4
- *
5
- * vim: shiftwidth=4
6
- */
7
-
8
- #ifndef __HITIMES_INTERVAL_H__
9
- #define __HITIMES_INTERVAL_H__
10
-
11
- #include <ruby.h>
12
-
13
- #define NANOSECONDS_PER_SECOND 1e9
14
-
15
- #ifdef USE_INSTANT_CLOCK_GETTIME
16
- # define HITIMES_U64INT unsigned long long int
17
- # define HITIMES_INSTANT_CONVERSION_FACTOR 1e9
18
- #elif USE_INSTANT_OSX
19
- # define HITIMES_U64INT unsigned long long int
20
- # define HITIMES_INSTANT_CONVERSION_FACTOR 1e9
21
- #elif USE_INSTANT_WINDOWS
22
- # define HITIMES_U64INT unsigned __int64
23
- # define HITIMES_INSTANT_CONVERSION_FACTOR hitimes_instant_conversion_factor()
24
- #else
25
- # error "Unable to build hitimes, no Instance backend available"
26
- #endif
27
-
28
-
29
- /* an alias for a 64bit unsigned integer. The various sytem dependenent
30
- * files must define hitimes_u64int_t
31
- */
32
- typedef HITIMES_U64INT hitimes_instant_t;
33
-
34
- typedef struct hitimes_interval {
35
- hitimes_instant_t start_instant;
36
- hitimes_instant_t stop_instant;
37
- VALUE duration;
38
- } hitimes_interval_t;
39
-
40
- /* all the backends must define this method */
41
- hitimes_instant_t hitimes_get_current_instant( );
42
- double hitimes_instant_conversion_factor( );
43
-
44
- /* init methods */
45
- void Init_hitimes_stats();
46
- void Init_hitimes_interval();
47
-
48
-
49
- /* Module and Classes -- defined at the top level */
50
- extern VALUE mH; /* module Hitimes */
51
- extern VALUE eH_Error; /* class Hitimes::Error */
52
- extern VALUE cH_Interval; /* class Hitimes::Interval */
53
-
54
-
55
- /**
56
- * Methods for Interval
57
- */
58
-
59
- VALUE hitimes_interval_free(hitimes_interval_t* i) ;
60
- VALUE hitimes_interval_alloc(VALUE klass);
61
- VALUE hitimes_interval_now( VALUE self );
62
- VALUE hitimes_interval_measure( VALUE self );
63
- VALUE hitimes_interval_split( VALUE self );
64
- VALUE hitimes_interval_start( VALUE self );
65
- VALUE hitimes_interval_stop( VALUE self );
66
- VALUE hitimes_interval_started( VALUE self );
67
- VALUE hitimes_interval_stopped( VALUE self );
68
- VALUE hitimes_interval_running( VALUE self );
69
- VALUE hitimes_interval_start_instant( VALUE self );
70
- VALUE hitimes_interval_stop_instant( VALUE self );
71
- VALUE hitimes_interval_duration ( VALUE self );
72
-
73
- #endif