hitimes 1.2.6-java → 1.3.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +6 -0
- data/README.md +3 -0
- data/ext/hitimes/c/hitimes.c +17 -1
- data/ext/hitimes/java/src/hitimes/Hitimes.java +16 -4
- data/ext/hitimes/java/src/hitimes/HitimesInterval.java +4 -9
- data/ext/hitimes/java/src/hitimes/HitimesService.java +1 -1
- data/lib/hitimes/hitimes.jar +0 -0
- data/lib/hitimes/version.rb +1 -1
- data/spec/hitimes_spec.rb +10 -0
- data/tasks/default.rake +3 -3
- data/tasks/extension.rake +3 -3
- data/tasks/this.rb +3 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7fb91409f02b2e5af0f16c4d5d16ecaa9c4ef077f27ef4d8234572f623248d1
|
4
|
+
data.tar.gz: 240b093ab591f704169d8caa0caacbbf3b233a0206f815b3e29ce0fe04e6e6d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbf663cc05e0807609461c6889e9a25368593011803f7eb253be0caf59822cd7b5340079c4e8238cc0a2e7a19162e3da73645543be2cdfdf42769dbb0afec817
|
7
|
+
data.tar.gz: 30fedc4a26b69fb6d9ee8fd32015a7f1964696af5a8ec864b995014f3188012889e6b6ceaff50bc691661a4544897f1ac5575b90d253d092a1d1dba549d9d42f
|
data/HISTORY.md
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
# Hitimes Changelog
|
2
|
+
## Version 1.3.0 2018-06-15
|
3
|
+
|
4
|
+
* Add api method `Hitimes.raw_instant` to expose raw OS instant value
|
5
|
+
* Add api constant `Hitimes::INSTANT_CONVERSION_FACTOR` to expose raw OS instant conversion factor
|
6
|
+
* other development cleanup tasks
|
7
|
+
|
2
8
|
## Version 1.2.6 2017-08-04
|
3
9
|
|
4
10
|
* Resolve version number issue (#61) (thanks @anthraxx)
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Hitimes
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/copiousfreetime/hitimes.svg?branch=master)](https://travis-ci.org/copiousfreetime/hitimes)
|
4
|
+
|
3
5
|
A fast, high resolution timer library for recording peformance metrics.
|
4
6
|
|
5
7
|
* [Homepage](http://github.com/copiousfreetime/hitimes)
|
@@ -15,6 +17,7 @@ A fast, high resolution timer library for recording peformance metrics.
|
|
15
17
|
* [Support](#support)
|
16
18
|
* [License](#license)
|
17
19
|
|
20
|
+
|
18
21
|
## Requirements
|
19
22
|
|
20
23
|
Hitimes requires the following to run:
|
data/ext/hitimes/c/hitimes.c
CHANGED
@@ -5,6 +5,20 @@
|
|
5
5
|
VALUE mH; /* module Hitimes */
|
6
6
|
VALUE eH_Error; /* class Hitimes::Error */
|
7
7
|
|
8
|
+
|
9
|
+
/**
|
10
|
+
* call-seq:
|
11
|
+
* Hitimes.raw_instant -> Integer
|
12
|
+
*
|
13
|
+
* Return the raw instant value from the operating system
|
14
|
+
*/
|
15
|
+
VALUE hitimes_instant_raw( )
|
16
|
+
{
|
17
|
+
unsigned long long i = (unsigned long long)hitimes_get_current_instant( );
|
18
|
+
|
19
|
+
return ULL2NUM(i);
|
20
|
+
}
|
21
|
+
|
8
22
|
/*
|
9
23
|
* Document-class: Hitimes::Error
|
10
24
|
*
|
@@ -13,8 +27,10 @@ VALUE eH_Error; /* class Hitimes::Error */
|
|
13
27
|
void Init_hitimes( )
|
14
28
|
{
|
15
29
|
mH = rb_define_module("Hitimes");
|
16
|
-
|
30
|
+
|
17
31
|
eH_Error = rb_define_class_under(mH, "Error", rb_eStandardError);
|
32
|
+
rb_define_const( mH, "INSTANT_CONVERSION_FACTOR", DBL2NUM( HITIMES_INSTANT_CONVERSION_FACTOR ));
|
33
|
+
rb_define_module_function( mH, "raw_instant", hitimes_instant_raw, 0 );
|
18
34
|
|
19
35
|
Init_hitimes_interval();
|
20
36
|
Init_hitimes_stats( );
|
@@ -4,7 +4,10 @@ import java.lang.Math;
|
|
4
4
|
import java.lang.System;
|
5
5
|
|
6
6
|
import org.jruby.anno.JRubyClass;
|
7
|
+
import org.jruby.anno.JRubyMethod;
|
7
8
|
import org.jruby.anno.JRubyModule;
|
9
|
+
import org.jruby.anno.JRubyConstant;
|
10
|
+
import org.jruby.runtime.Visibility;
|
8
11
|
|
9
12
|
import org.jruby.Ruby;
|
10
13
|
import org.jruby.RubyClass;
|
@@ -14,6 +17,8 @@ import org.jruby.RubyObject;
|
|
14
17
|
|
15
18
|
import org.jruby.exceptions.RaiseException;
|
16
19
|
|
20
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
21
|
+
|
17
22
|
|
18
23
|
/**
|
19
24
|
* @author <a href="mailto:jeremy@hinegardner.org">Jeremy Hinegardner</a>
|
@@ -21,12 +26,18 @@ import org.jruby.exceptions.RaiseException;
|
|
21
26
|
@JRubyModule( name = "Hitimes" )
|
22
27
|
public class Hitimes {
|
23
28
|
|
29
|
+
public static final double INSTANT_CONVERSION_FACTOR = 1000000000d;
|
30
|
+
|
31
|
+
private static final Ruby __ruby__ = Ruby.getGlobalRuntime();
|
32
|
+
|
24
33
|
public static RubyClass hitimesIntervalClass;
|
25
34
|
/**
|
26
35
|
* Create the Hitimes module and add it to the Ruby runtime.
|
27
36
|
*/
|
28
|
-
public static RubyModule
|
37
|
+
public static RubyModule createHitimesModule( Ruby runtime ) {
|
29
38
|
RubyModule mHitimes = runtime.defineModule("Hitimes");
|
39
|
+
mHitimes.defineConstant("INSTANT_CONVERSION_FACTOR", __ruby__.newFloat(INSTANT_CONVERSION_FACTOR));
|
40
|
+
mHitimes.defineAnnotatedMethods( Hitimes.class );
|
30
41
|
|
31
42
|
RubyClass cStandardError = runtime.getStandardError();
|
32
43
|
RubyClass cHitimesError = mHitimes.defineClassUnder("Error", cStandardError, cStandardError.getAllocator());
|
@@ -47,8 +58,9 @@ public class Hitimes {
|
|
47
58
|
}
|
48
59
|
|
49
60
|
|
50
|
-
|
51
|
-
|
52
|
-
|
61
|
+
@JRubyMethod( name = "raw_instant", module = true )
|
62
|
+
public static IRubyObject rawInstant(IRubyObject self) {
|
63
|
+
return __ruby__.newFixnum( System.nanoTime() );
|
64
|
+
}
|
53
65
|
|
54
66
|
}
|
@@ -16,11 +16,6 @@ import org.jruby.anno.JRubyMethod;
|
|
16
16
|
@JRubyClass( name = "Hitimes::Interval" )
|
17
17
|
public class HitimesInterval extends RubyObject {
|
18
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
19
|
private static final long INSTANT_NOT_SET = Long.MIN_VALUE;
|
25
20
|
private static final double DURATION_NOT_SET = Double.NaN;
|
26
21
|
|
@@ -58,7 +53,7 @@ public class HitimesInterval extends RubyObject {
|
|
58
53
|
* if stop has not yet been called, then return the amount of time so far
|
59
54
|
*/
|
60
55
|
if ( INSTANT_NOT_SET == this.stop_instant ) {
|
61
|
-
double d = ( System.nanoTime() - this.start_instant ) / INSTANT_CONVERSION_FACTOR;
|
56
|
+
double d = ( System.nanoTime() - this.start_instant ) / Hitimes.INSTANT_CONVERSION_FACTOR;
|
62
57
|
return getRuntime().newFloat( d );
|
63
58
|
}
|
64
59
|
|
@@ -66,7 +61,7 @@ public class HitimesInterval extends RubyObject {
|
|
66
61
|
* if stop has been called, then calculate the duration and return
|
67
62
|
*/
|
68
63
|
if ( DURATION_NOT_SET == this.duration ) {
|
69
|
-
this.duration = (this.stop_instant - this.start_instant) / INSTANT_CONVERSION_FACTOR;
|
64
|
+
this.duration = (this.stop_instant - this.start_instant) / Hitimes.INSTANT_CONVERSION_FACTOR;
|
70
65
|
}
|
71
66
|
|
72
67
|
return getRuntime().newFloat( this.duration );
|
@@ -82,7 +77,7 @@ public class HitimesInterval extends RubyObject {
|
|
82
77
|
}
|
83
78
|
|
84
79
|
if ( INSTANT_NOT_SET == this.stop_instant ) {
|
85
|
-
double d = ( System.nanoTime() - this.start_instant ) / INSTANT_CONVERSION_FACTOR;
|
80
|
+
double d = ( System.nanoTime() - this.start_instant ) / Hitimes.INSTANT_CONVERSION_FACTOR;
|
86
81
|
return getRuntime().newFloat( d );
|
87
82
|
}
|
88
83
|
|
@@ -140,7 +135,7 @@ public class HitimesInterval extends RubyObject {
|
|
140
135
|
|
141
136
|
if ( INSTANT_NOT_SET == this.stop_instant ) {
|
142
137
|
this.stop_instant = System.nanoTime();
|
143
|
-
this.duration = (this.stop_instant - this.start_instant) / INSTANT_CONVERSION_FACTOR;
|
138
|
+
this.duration = (this.stop_instant - this.start_instant) / Hitimes.INSTANT_CONVERSION_FACTOR;
|
144
139
|
return getRuntime().newFloat( this.duration );
|
145
140
|
}
|
146
141
|
|
@@ -8,7 +8,7 @@ import org.jruby.runtime.load.BasicLibraryService;
|
|
8
8
|
|
9
9
|
public class HitimesService implements BasicLibraryService {
|
10
10
|
public boolean basicLoad( final Ruby runtime ) throws IOException {
|
11
|
-
Hitimes.
|
11
|
+
Hitimes.createHitimesModule( runtime );
|
12
12
|
return true;
|
13
13
|
}
|
14
14
|
}
|
data/lib/hitimes/hitimes.jar
CHANGED
Binary file
|
data/lib/hitimes/version.rb
CHANGED
data/spec/hitimes_spec.rb
CHANGED
@@ -11,4 +11,14 @@ describe Hitimes do
|
|
11
11
|
it "raises an error if measure is called with no block" do
|
12
12
|
lambda{ Hitimes.measure }.must_raise( Hitimes::Error )
|
13
13
|
end
|
14
|
+
|
15
|
+
it "has the raw instant value" do
|
16
|
+
v = Hitimes.raw_instant
|
17
|
+
v.must_be :>, 0
|
18
|
+
end
|
19
|
+
|
20
|
+
it "has access to the instant conversion factor" do
|
21
|
+
f = Hitimes::INSTANT_CONVERSION_FACTOR
|
22
|
+
f.must_be :>, 0
|
23
|
+
end
|
14
24
|
end
|
data/tasks/default.rake
CHANGED
@@ -24,7 +24,7 @@ namespace :develop do
|
|
24
24
|
File.open( "Gemfile", "w+" ) do |f|
|
25
25
|
f.puts "# DO NOT EDIT - This file is automatically generated"
|
26
26
|
f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
|
27
|
-
f.puts 'source "https://rubygems.org
|
27
|
+
f.puts 'source "https://rubygems.org"'
|
28
28
|
f.puts 'gemspec'
|
29
29
|
end
|
30
30
|
end
|
@@ -38,7 +38,7 @@ task :develop => "develop:default"
|
|
38
38
|
begin
|
39
39
|
require 'rake/testtask'
|
40
40
|
Rake::TestTask.new( :test ) do |t|
|
41
|
-
t.ruby_opts = %w[ -w
|
41
|
+
t.ruby_opts = %w[ -w ]
|
42
42
|
t.libs = %w[ lib spec test ]
|
43
43
|
t.pattern = "{test,spec}/**/{test_*,*_spec}.rb"
|
44
44
|
end
|
@@ -80,7 +80,7 @@ begin
|
|
80
80
|
ENV['COVERAGE'] = 'true'
|
81
81
|
Rake::Task[:test].execute
|
82
82
|
end
|
83
|
-
CLOBBER << 'coverage' if File.directory?('coverage')
|
83
|
+
CLOBBER << 'coverage' if File.directory?( 'coverage' )
|
84
84
|
rescue LoadError
|
85
85
|
This.task_warning( 'simplecov' )
|
86
86
|
end
|
data/tasks/extension.rake
CHANGED
@@ -23,9 +23,9 @@ begin
|
|
23
23
|
ext.lib_dir = File.join( 'lib', This.name )
|
24
24
|
ext.gem_spec = This.ruby_gemspec
|
25
25
|
|
26
|
-
ext.cross_compile = true
|
27
|
-
ext.cross_platform =
|
28
|
-
|
26
|
+
ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
|
27
|
+
ext.cross_platform = %w[x86-mingw32 x64-mingw32] # forces the Windows platform instead of the default one
|
28
|
+
# configure options only for cross compile
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
data/tasks/this.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hitimes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Jeremy Hinegardner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,9 +108,10 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0.14'
|
111
|
-
description:
|
112
|
-
|
113
|
-
|
111
|
+
description: "(https://travis-ci.org/copiousfreetime/hitimes.svg?branch=master)](https://travis-ci.org/copiousfreetime/hitimes)\
|
112
|
+
\ A fast, high resolution timer library for recording peformance metrics. * (http://github.com/copiousfreetime/hitimes)\
|
113
|
+
\ * (http://github.com.org/copiousfreetime/hitimes) * email jeremy at copiousfreetime\
|
114
|
+
\ dot org * `git clone url git://github.com/copiousfreetime/hitimes.git`"
|
114
115
|
email: jeremy@copiousfreetime.org
|
115
116
|
executables: []
|
116
117
|
extensions: []
|
@@ -189,10 +190,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
190
|
version: '0'
|
190
191
|
requirements: []
|
191
192
|
rubyforge_project:
|
192
|
-
rubygems_version: 2.6
|
193
|
+
rubygems_version: 2.7.6
|
193
194
|
signing_key:
|
194
195
|
specification_version: 4
|
195
|
-
summary:
|
196
|
+
summary: "[![Build Status](https://travis-ci.org/copiousfreetime/hitimes.svg?branch=master)](https://travis-ci.org/copiousfreetime/hitimes)"
|
196
197
|
test_files:
|
197
198
|
- spec/hitimes_spec.rb
|
198
199
|
- spec/interval_spec.rb
|