hitimes 1.2.6 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50d7f140e090285423902516acfdb1853aaee2e9
4
- data.tar.gz: ccf795402dde6d695663595409b1aaeace2867d9
3
+ metadata.gz: 7f524a821dc9c99b61be2c3af977e825f9ca7ed2
4
+ data.tar.gz: ff3e5a216ba2b504f49dd13d612b843c48855bd3
5
5
  SHA512:
6
- metadata.gz: 351917724348a7cd51eb1bd67edbe1369797956c98708801ab8c61d8699cc8f2efff7fd3724a429a837184ef5caf031d76f70bf4c86a55661b075aac037171cb
7
- data.tar.gz: 478abe6d82eb9898b6ea1e54cafe560b59a69e2c0b5b572d749bb6a2dff0f95e1ec8ee2e024d904c9c27c4f8f6f1f5640b777e91461b859a664687479b472caa
6
+ metadata.gz: bcf7ba65f863b4ed3376a42ab9adac359ccd751a8b9f97ac3c606792cef80ece1325590e5eda9580da15f84e7817af4c4a8b80e444f7a8e85725e2e93a77f67f
7
+ data.tar.gz: 1d25a2c4afedaaa53aed97ad47197121227aab88dbba57faa6ffc32566454617b2821f42289ca63c3dda0dc6c131c81e400aa1e6746f01dfc7b2fef75567b8ce
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:
@@ -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 createHitimes( Ruby runtime ) {
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
- @JRubyClass( name = "Hitimes::Error", parent = "StandardError" )
52
- public static class Error {};
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.createHitimes( runtime );
11
+ Hitimes.createHitimesModule( runtime );
12
12
  return true;
13
13
  }
14
14
  }
@@ -4,5 +4,5 @@
4
4
  #++
5
5
 
6
6
  module Hitimes
7
- VERSION = "1.2.6"
7
+ VERSION = "1.3.0"
8
8
  end
@@ -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
@@ -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 -rubygems ]
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
@@ -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 # enable cross compilation (requires cross compile toolchain)
27
- ext.cross_platform = 'i386-mingw32' # forces the Windows platform instead of the default one
28
- # configure options only for cross compile
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
 
@@ -194,7 +194,9 @@ class ThisProject
194
194
  end
195
195
 
196
196
  def license
197
- "ISC"
197
+ license_file = project_path("LICENSE")
198
+ line = license_file.readlines.first
199
+ line.split(/\s+/).first
198
200
  end
199
201
 
200
202
  # Internal: The path to the gemspec file
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.2.6
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Hinegardner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-04 00:00:00.000000000 Z
11
+ date: 2018-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -108,9 +108,10 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.14'
111
- description: A fast, high resolution timer library for recording peformance metrics.
112
- * (http://github.com/copiousfreetime/hitimes) * (http://github.com.org/copiousfreetime/hitimes)
113
- * email jeremy at copiousfreetime dot org * `git clone url git://github.com/copiousfreetime/hitimes.git`
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.11
193
+ rubygems_version: 2.6.12
193
194
  signing_key:
194
195
  specification_version: 4
195
- summary: A fast, high resolution timer library for recording peformance metrics.
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