hitimes 1.1.1-x86-mingw32 → 1.2.2-x86-mingw32
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/.travis.yml +10 -0
- data/CONTRIBUTING.md +45 -0
- data/{HISTORY → HISTORY.md} +42 -18
- data/LICENSE +11 -8
- data/Manifest.txt +45 -0
- data/README.md +163 -0
- data/Rakefile +23 -62
- data/ext/hitimes/c/extconf.rb +24 -0
- data/ext/hitimes/{hitimes_ext.c → c/hitimes.c} +1 -1
- data/ext/hitimes/{hitimes_instant_clock_gettime.c → c/hitimes_instant_clock_gettime.c} +0 -0
- data/ext/hitimes/c/hitimes_instant_osx.c +45 -0
- data/ext/hitimes/{hitimes_instant_windows.c → c/hitimes_instant_windows.c} +0 -0
- data/ext/hitimes/{hitimes_interval.c → c/hitimes_interval.c} +15 -7
- data/ext/hitimes/{hitimes_interval.h → c/hitimes_interval.h} +5 -5
- data/ext/hitimes/{hitimes_stats.c → c/hitimes_stats.c} +0 -0
- data/ext/hitimes/{hitimes_stats.h → c/hitimes_stats.h} +0 -0
- data/ext/hitimes/java/src/hitimes/Hitimes.java +54 -0
- data/ext/hitimes/java/src/hitimes/HitimesInterval.java +181 -0
- data/ext/hitimes/java/src/hitimes/HitimesService.java +16 -0
- data/ext/hitimes/java/src/hitimes/HitimesStats.java +112 -0
- data/lib/hitimes.rb +15 -5
- data/lib/hitimes/1.9/hitimes.so +0 -0
- data/lib/hitimes/2.0/hitimes.so +0 -0
- data/lib/hitimes/2.1/hitimes.so +0 -0
- data/lib/hitimes/version.rb +1 -50
- data/spec/hitimes_spec.rb +14 -0
- data/spec/interval_spec.rb +40 -37
- data/spec/metric_spec.rb +8 -10
- data/spec/mutex_stats_spec.rb +10 -8
- data/spec/paths_spec.rb +3 -5
- data/spec/spec_helper.rb +9 -3
- data/spec/stats_spec.rb +28 -30
- data/spec/timed_metric_spec.rb +42 -42
- data/spec/timed_value_metric_spec.rb +54 -55
- data/spec/value_metric_spec.rb +26 -28
- data/spec/version_spec.rb +4 -30
- data/tasks/default.rake +242 -0
- data/tasks/extension.rake +31 -101
- data/tasks/this.rb +206 -0
- metadata +158 -145
- data/README +0 -135
- data/ext/hitimes/extconf.rb +0 -17
- data/ext/hitimes/hitimes_instant_osx.c +0 -16
- data/gemspec.rb +0 -64
- data/lib/hitimes/1.8/hitimes_ext.so +0 -0
- data/lib/hitimes/1.9/hitimes_ext.so +0 -0
- data/tasks/announce.rake +0 -42
- data/tasks/config.rb +0 -109
- data/tasks/distribution.rake +0 -93
- data/tasks/documentation.rake +0 -32
- data/tasks/rspec.rake +0 -33
- data/tasks/rubyforge.rake +0 -55
- data/tasks/utils.rb +0 -80
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
require 'mkmf'
|
3
|
+
|
4
|
+
if RbConfig::CONFIG['host_os'] =~ /darwin/ then
|
5
|
+
$CFLAGS += " -DUSE_INSTANT_OSX=1 -Wall"
|
6
|
+
$LDFLAGS += " -framework CoreServices"
|
7
|
+
elsif RbConfig::CONFIG['host_os'] =~ /win32/ or RbConfig::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
|
+
elsif have_library("c", "clock_gettime") then
|
13
|
+
$CFLAGS += " -DUSE_INSTANT_CLOCK_GETTIME=1"
|
14
|
+
else
|
15
|
+
raise NotImplementedError, <<-_
|
16
|
+
Unable to find the function 'clock_gettime' in either libc or librt.
|
17
|
+
Please file an issue at https://github.com/copiousfreetime/hitimes.
|
18
|
+
_
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# put in a different location if on windows so we can have fat binaries
|
23
|
+
subdir = RUBY_VERSION.gsub(/\.\d$/,'')
|
24
|
+
create_makefile("hitimes/#{subdir}/hitimes")
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#ifdef USE_INSTANT_OSX
|
2
|
+
|
3
|
+
#include "hitimes_interval.h"
|
4
|
+
#include <mach/mach.h>
|
5
|
+
#include <mach/mach_time.h>
|
6
|
+
|
7
|
+
/* All this OSX code is adapted from http://developer.apple.com/library/mac/#qa/qa1398/_index.html */
|
8
|
+
|
9
|
+
/*
|
10
|
+
* returns the conversion factor, this value is used to convert
|
11
|
+
* the value from hitimes_get_current_instant() into seconds
|
12
|
+
*/
|
13
|
+
long double hitimes_instant_conversion_factor()
|
14
|
+
{
|
15
|
+
static mach_timebase_info_data_t s_timebase_info;
|
16
|
+
static long double conversion_factor;
|
17
|
+
static uint64_t nano_conversion;
|
18
|
+
|
19
|
+
/**
|
20
|
+
* If this is the first time we've run, get the timebase.
|
21
|
+
* We can use denom == 0 to indicate that s_timebase_info is
|
22
|
+
* uninitialised because it makes no sense to have a zero
|
23
|
+
* denominator is a fraction.
|
24
|
+
*/
|
25
|
+
|
26
|
+
if ( s_timebase_info.denom == 0 ) {
|
27
|
+
mach_timebase_info(&s_timebase_info);
|
28
|
+
nano_conversion = s_timebase_info.numer / s_timebase_info.denom;
|
29
|
+
conversion_factor = (long double) (nano_conversion) * (1e9l);
|
30
|
+
}
|
31
|
+
|
32
|
+
return conversion_factor;
|
33
|
+
}
|
34
|
+
|
35
|
+
/*
|
36
|
+
* returns the mach absolute time, which has no meaning outside of a conversion
|
37
|
+
* factor.
|
38
|
+
*/
|
39
|
+
hitimes_instant_t hitimes_get_current_instant()
|
40
|
+
{
|
41
|
+
return mach_absolute_time();
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
#endif
|
File without changes
|
@@ -39,7 +39,7 @@ VALUE hitimes_interval_alloc(VALUE klass)
|
|
39
39
|
*
|
40
40
|
* Create an interval that has already started
|
41
41
|
*/
|
42
|
-
VALUE hitimes_interval_now(
|
42
|
+
VALUE hitimes_interval_now( )
|
43
43
|
{
|
44
44
|
VALUE obj;
|
45
45
|
hitimes_interval_t *i = xmalloc( sizeof( hitimes_interval_t ) );
|
@@ -59,7 +59,7 @@ VALUE hitimes_interval_now( VALUE self )
|
|
59
59
|
*
|
60
60
|
* Times the execution of the block returning the number of seconds it took
|
61
61
|
*/
|
62
|
-
VALUE hitimes_interval_measure(
|
62
|
+
VALUE hitimes_interval_measure( )
|
63
63
|
{
|
64
64
|
hitimes_instant_t before;
|
65
65
|
hitimes_instant_t after;
|
@@ -68,7 +68,7 @@ VALUE hitimes_interval_measure( VALUE self )
|
|
68
68
|
if ( !rb_block_given_p() ) {
|
69
69
|
rb_raise(eH_Error, "No block given to Interval.measure" );
|
70
70
|
}
|
71
|
-
|
71
|
+
|
72
72
|
before = hitimes_get_current_instant( );
|
73
73
|
rb_yield( Qnil );
|
74
74
|
after = hitimes_get_current_instant( );
|
@@ -105,7 +105,7 @@ VALUE hitimes_interval_split( VALUE self )
|
|
105
105
|
|
106
106
|
/**
|
107
107
|
* call-seq:
|
108
|
-
* interval.start -> boolean
|
108
|
+
* interval.start -> boolean
|
109
109
|
*
|
110
110
|
* mark the start of the interval. Calling start on an already started
|
111
111
|
* interval has no effect. An interval can only be started once. If the
|
@@ -144,7 +144,7 @@ VALUE hitimes_interval_stop( VALUE self )
|
|
144
144
|
|
145
145
|
Data_Get_Struct( self, hitimes_interval_t, i );
|
146
146
|
if ( 0L == i->start_instant ) {
|
147
|
-
rb_raise(eH_Error, "Attempt to stop an interval that has not started
|
147
|
+
rb_raise(eH_Error, "Attempt to stop an interval that has not started" );
|
148
148
|
}
|
149
149
|
|
150
150
|
if ( 0L == i->stop_instant ) {
|
@@ -281,6 +281,8 @@ VALUE hitimes_interval_stop_instant( VALUE self )
|
|
281
281
|
* Returns the Float value of the interval, the value is in seconds. If the
|
282
282
|
* interval has not had stop called yet, it will report the number of seconds
|
283
283
|
* in the interval up to the current point in time.
|
284
|
+
*
|
285
|
+
* Raises Error if duration is called on an interval that has not started yet.
|
284
286
|
*/
|
285
287
|
VALUE hitimes_interval_duration ( VALUE self )
|
286
288
|
{
|
@@ -288,7 +290,13 @@ VALUE hitimes_interval_duration ( VALUE self )
|
|
288
290
|
|
289
291
|
Data_Get_Struct( self, hitimes_interval_t, i );
|
290
292
|
|
291
|
-
|
293
|
+
/* raise an error if the internval is not started */
|
294
|
+
if ( 0L == i->start_instant ) {
|
295
|
+
rb_raise(eH_Error, "Attempt to report a duration on an interval that has not started" );
|
296
|
+
}
|
297
|
+
|
298
|
+
|
299
|
+
/**
|
292
300
|
* if stop has not yet been called, then return the amount of time so far
|
293
301
|
*/
|
294
302
|
if ( 0L == i->stop_instant ) {
|
@@ -296,7 +304,7 @@ VALUE hitimes_interval_duration ( VALUE self )
|
|
296
304
|
hitimes_instant_t now = hitimes_get_current_instant( );
|
297
305
|
d = ( now - i->start_instant ) / HITIMES_INSTANT_CONVERSION_FACTOR;
|
298
306
|
return rb_float_new( d );
|
299
|
-
}
|
307
|
+
}
|
300
308
|
|
301
309
|
/*
|
302
310
|
* stop has been called, calculate the duration and save the result
|
@@ -16,8 +16,8 @@
|
|
16
16
|
# define HITIMES_U64INT unsigned long long int
|
17
17
|
# define HITIMES_INSTANT_CONVERSION_FACTOR 1e9l
|
18
18
|
#elif USE_INSTANT_OSX
|
19
|
-
# define HITIMES_U64INT
|
20
|
-
# define HITIMES_INSTANT_CONVERSION_FACTOR
|
19
|
+
# define HITIMES_U64INT uint64_t
|
20
|
+
# define HITIMES_INSTANT_CONVERSION_FACTOR hitimes_instant_conversion_factor()
|
21
21
|
#elif USE_INSTANT_WINDOWS
|
22
22
|
# define HITIMES_U64INT unsigned __int64
|
23
23
|
# define HITIMES_INSTANT_CONVERSION_FACTOR hitimes_instant_conversion_factor()
|
@@ -37,7 +37,7 @@ typedef struct hitimes_interval {
|
|
37
37
|
long double duration;
|
38
38
|
} hitimes_interval_t;
|
39
39
|
|
40
|
-
/* all the backends must define
|
40
|
+
/* all the backends must define these methods */
|
41
41
|
hitimes_instant_t hitimes_get_current_instant( );
|
42
42
|
long double hitimes_instant_conversion_factor( );
|
43
43
|
|
@@ -58,8 +58,8 @@ extern VALUE cH_Interval; /* class Hitimes::Interval */
|
|
58
58
|
|
59
59
|
VALUE hitimes_interval_free(hitimes_interval_t* i) ;
|
60
60
|
VALUE hitimes_interval_alloc(VALUE klass);
|
61
|
-
VALUE hitimes_interval_now(
|
62
|
-
VALUE hitimes_interval_measure(
|
61
|
+
VALUE hitimes_interval_now( );
|
62
|
+
VALUE hitimes_interval_measure( );
|
63
63
|
VALUE hitimes_interval_split( VALUE self );
|
64
64
|
VALUE hitimes_interval_start( VALUE self );
|
65
65
|
VALUE hitimes_interval_stop( VALUE self );
|
File without changes
|
File without changes
|
@@ -0,0 +1,54 @@
|
|
1
|
+
package hitimes;
|
2
|
+
|
3
|
+
import java.lang.Math;
|
4
|
+
import java.lang.System;
|
5
|
+
|
6
|
+
import org.jruby.anno.JRubyClass;
|
7
|
+
import org.jruby.anno.JRubyModule;
|
8
|
+
|
9
|
+
import org.jruby.Ruby;
|
10
|
+
import org.jruby.RubyClass;
|
11
|
+
import org.jruby.RubyException;
|
12
|
+
import org.jruby.RubyModule;
|
13
|
+
import org.jruby.RubyObject;
|
14
|
+
|
15
|
+
import org.jruby.exceptions.RaiseException;
|
16
|
+
|
17
|
+
|
18
|
+
/**
|
19
|
+
* @author <a href="mailto:jeremy@hinegardner.org">Jeremy Hinegardner</a>
|
20
|
+
*/
|
21
|
+
@JRubyModule( name = "Hitimes" )
|
22
|
+
public class Hitimes {
|
23
|
+
|
24
|
+
public static RubyClass hitimesIntervalClass;
|
25
|
+
/**
|
26
|
+
* Create the Hitimes module and add it to the Ruby runtime.
|
27
|
+
*/
|
28
|
+
public static RubyModule createHitimes( Ruby runtime ) {
|
29
|
+
RubyModule mHitimes = runtime.defineModule("Hitimes");
|
30
|
+
|
31
|
+
RubyClass cStandardError = runtime.getStandardError();
|
32
|
+
RubyClass cHitimesError = mHitimes.defineClassUnder("Error", cStandardError, cStandardError.getAllocator());
|
33
|
+
|
34
|
+
RubyClass cHitimesStats = mHitimes.defineClassUnder("Stats", runtime.getObject(), HitimesStats.ALLOCATOR );
|
35
|
+
cHitimesStats.defineAnnotatedMethods( HitimesStats.class );
|
36
|
+
|
37
|
+
RubyClass cHitimesInterval = mHitimes.defineClassUnder("Interval", runtime.getObject(), HitimesInterval.ALLOCATOR );
|
38
|
+
Hitimes.hitimesIntervalClass = cHitimesInterval;
|
39
|
+
cHitimesInterval.defineAnnotatedMethods( HitimesInterval.class );
|
40
|
+
|
41
|
+
return mHitimes;
|
42
|
+
}
|
43
|
+
|
44
|
+
static RaiseException newHitimesError( Ruby runtime, String message ) {
|
45
|
+
RubyClass errorClass = runtime.getModule("Hitimes").getClass( "Error" );
|
46
|
+
return new RaiseException( RubyException.newException( runtime, errorClass, message ), true );
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
@JRubyClass( name = "Hitimes::Error", parent = "StandardError" )
|
52
|
+
public static class Error {};
|
53
|
+
|
54
|
+
}
|
@@ -0,0 +1,181 @@
|
|
1
|
+
package hitimes;
|
2
|
+
|
3
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
4
|
+
|
5
|
+
import org.jruby.Ruby;
|
6
|
+
import org.jruby.RubyClass;
|
7
|
+
import org.jruby.RubyObject;
|
8
|
+
|
9
|
+
import org.jruby.runtime.Block;
|
10
|
+
import org.jruby.runtime.ObjectAllocator;
|
11
|
+
import org.jruby.runtime.ThreadContext;
|
12
|
+
|
13
|
+
import org.jruby.anno.JRubyClass;
|
14
|
+
import org.jruby.anno.JRubyMethod;
|
15
|
+
|
16
|
+
@JRubyClass( name = "Hitimes::Interval" )
|
17
|
+
public class HitimesInterval extends RubyObject {
|
18
|
+
|
19
|
+
/* this is a double to force all division by the conversion factor
|
20
|
+
* to cast to doubles
|
21
|
+
*/
|
22
|
+
private static final double INSTANT_CONVERSION_FACTOR = 1000000000d;
|
23
|
+
|
24
|
+
private static final long INSTANT_NOT_SET = Long.MIN_VALUE;
|
25
|
+
private static final double DURATION_NOT_SET = Double.NaN;
|
26
|
+
|
27
|
+
public static final ObjectAllocator ALLOCATOR = new ObjectAllocator() {
|
28
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
|
29
|
+
return new HitimesInterval( runtime, klass );
|
30
|
+
}
|
31
|
+
};
|
32
|
+
|
33
|
+
public HitimesInterval( Ruby runtime, RubyClass klass ) {
|
34
|
+
super( runtime, klass );
|
35
|
+
}
|
36
|
+
|
37
|
+
public HitimesInterval( Ruby runtime, RubyClass klass, long start ) {
|
38
|
+
super( runtime, klass );
|
39
|
+
this.start_instant = start;
|
40
|
+
}
|
41
|
+
|
42
|
+
|
43
|
+
private long start_instant = INSTANT_NOT_SET;
|
44
|
+
private long stop_instant = INSTANT_NOT_SET;
|
45
|
+
private double duration = DURATION_NOT_SET;
|
46
|
+
|
47
|
+
@JRubyMethod( name = "duration", alias = { "length", "to_f", "to_seconds" } )
|
48
|
+
public IRubyObject duration() {
|
49
|
+
|
50
|
+
/*
|
51
|
+
* if start has not yet been called, then raise an exception.
|
52
|
+
*/
|
53
|
+
if ( INSTANT_NOT_SET == this.start_instant ) {
|
54
|
+
throw Hitimes.newHitimesError( getRuntime(), "Attempt to report a duration on an interval that has not started");
|
55
|
+
}
|
56
|
+
|
57
|
+
/*
|
58
|
+
* if stop has not yet been called, then return the amount of time so far
|
59
|
+
*/
|
60
|
+
if ( INSTANT_NOT_SET == this.stop_instant ) {
|
61
|
+
double d = ( System.nanoTime() - this.start_instant ) / INSTANT_CONVERSION_FACTOR;
|
62
|
+
return getRuntime().newFloat( d );
|
63
|
+
}
|
64
|
+
|
65
|
+
/*
|
66
|
+
* if stop has been called, then calculate the duration and return
|
67
|
+
*/
|
68
|
+
if ( DURATION_NOT_SET == this.duration ) {
|
69
|
+
this.duration = (this.stop_instant - this.start_instant) / INSTANT_CONVERSION_FACTOR;
|
70
|
+
}
|
71
|
+
|
72
|
+
return getRuntime().newFloat( this.duration );
|
73
|
+
|
74
|
+
}
|
75
|
+
|
76
|
+
@JRubyMethod( name = "duration_so_far" )
|
77
|
+
public IRubyObject duration_so_far() {
|
78
|
+
IRubyObject rc = getRuntime().getFalse();
|
79
|
+
|
80
|
+
if ( INSTANT_NOT_SET == this.start_instant ) {
|
81
|
+
return rc;
|
82
|
+
}
|
83
|
+
|
84
|
+
if ( INSTANT_NOT_SET == this.stop_instant ) {
|
85
|
+
double d = ( System.nanoTime() - this.start_instant ) / INSTANT_CONVERSION_FACTOR;
|
86
|
+
return getRuntime().newFloat( d );
|
87
|
+
}
|
88
|
+
|
89
|
+
return rc;
|
90
|
+
}
|
91
|
+
|
92
|
+
@JRubyMethod( name = "started?" )
|
93
|
+
public IRubyObject is_started() {
|
94
|
+
if ( INSTANT_NOT_SET == this.start_instant ) {
|
95
|
+
return getRuntime().getFalse();
|
96
|
+
}
|
97
|
+
return getRuntime().getTrue();
|
98
|
+
}
|
99
|
+
|
100
|
+
@JRubyMethod( name = "running?" )
|
101
|
+
public IRubyObject is_running() {
|
102
|
+
if ( ( INSTANT_NOT_SET != this.start_instant ) && ( INSTANT_NOT_SET == this.stop_instant ) ) {
|
103
|
+
return getRuntime().getTrue();
|
104
|
+
}
|
105
|
+
return getRuntime().getFalse();
|
106
|
+
}
|
107
|
+
|
108
|
+
@JRubyMethod( name = "stopped?" )
|
109
|
+
public IRubyObject is_stopped() {
|
110
|
+
if ( INSTANT_NOT_SET == this.stop_instant ) {
|
111
|
+
return getRuntime().getFalse();
|
112
|
+
}
|
113
|
+
return getRuntime().getTrue();
|
114
|
+
}
|
115
|
+
|
116
|
+
@JRubyMethod( name = "start_instant" )
|
117
|
+
public IRubyObject start_instant() {
|
118
|
+
return getRuntime().newFixnum( this.start_instant );
|
119
|
+
}
|
120
|
+
|
121
|
+
@JRubyMethod( name = "stop_instant" )
|
122
|
+
public IRubyObject stop_instant() {
|
123
|
+
return getRuntime().newFixnum( this.stop_instant );
|
124
|
+
}
|
125
|
+
|
126
|
+
@JRubyMethod( name = "start" )
|
127
|
+
public IRubyObject start() {
|
128
|
+
if ( INSTANT_NOT_SET == this.start_instant ) {
|
129
|
+
this.start_instant = System.nanoTime();
|
130
|
+
return getRuntime().getTrue();
|
131
|
+
}
|
132
|
+
return getRuntime().getFalse();
|
133
|
+
}
|
134
|
+
|
135
|
+
@JRubyMethod( name = "stop" )
|
136
|
+
public IRubyObject stop() {
|
137
|
+
if ( INSTANT_NOT_SET == this.start_instant ) {
|
138
|
+
throw Hitimes.newHitimesError( getRuntime(), "Attempt to stop an interval that has not started" );
|
139
|
+
}
|
140
|
+
|
141
|
+
if ( INSTANT_NOT_SET == this.stop_instant ) {
|
142
|
+
this.stop_instant = System.nanoTime();
|
143
|
+
this.duration = (this.stop_instant - this.start_instant) / INSTANT_CONVERSION_FACTOR;
|
144
|
+
return getRuntime().newFloat( this.duration );
|
145
|
+
}
|
146
|
+
|
147
|
+
return getRuntime().getFalse();
|
148
|
+
}
|
149
|
+
|
150
|
+
@JRubyMethod( name = "split" )
|
151
|
+
public IRubyObject split() {
|
152
|
+
this.stop();
|
153
|
+
return new HitimesInterval( getRuntime(), Hitimes.hitimesIntervalClass, this.stop_instant );
|
154
|
+
}
|
155
|
+
|
156
|
+
@JRubyMethod( name = "now", module = true )
|
157
|
+
public static IRubyObject now( IRubyObject self ) {
|
158
|
+
return new HitimesInterval( self.getRuntime(), Hitimes.hitimesIntervalClass, System.nanoTime() );
|
159
|
+
}
|
160
|
+
|
161
|
+
@JRubyMethod( name = "measure", module = true, frame = true )
|
162
|
+
public static IRubyObject measure( IRubyObject self, Block block ) {
|
163
|
+
|
164
|
+
Ruby runtime = self.getRuntime();
|
165
|
+
|
166
|
+
if ( block.isGiven() ) {
|
167
|
+
IRubyObject nil = runtime.getNil();
|
168
|
+
ThreadContext context = runtime.getCurrentContext();
|
169
|
+
|
170
|
+
HitimesInterval interval = new HitimesInterval( runtime, Hitimes.hitimesIntervalClass );
|
171
|
+
|
172
|
+
interval.start();
|
173
|
+
block.yield( context, nil );
|
174
|
+
interval.stop();
|
175
|
+
|
176
|
+
return interval.duration();
|
177
|
+
} else {
|
178
|
+
throw Hitimes.newHitimesError( runtime, "No block given to Interval.measure" );
|
179
|
+
}
|
180
|
+
}
|
181
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
package hitimes;
|
2
|
+
|
3
|
+
import java.io.IOException;
|
4
|
+
|
5
|
+
import org.jruby.Ruby;
|
6
|
+
|
7
|
+
import org.jruby.runtime.load.BasicLibraryService;
|
8
|
+
|
9
|
+
public class HitimesService implements BasicLibraryService {
|
10
|
+
public boolean basicLoad( final Ruby runtime ) throws IOException {
|
11
|
+
Hitimes.createHitimes( runtime );
|
12
|
+
return true;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
|