hitimes 1.1.1-x86-mswin32 → 1.2.0-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING.md +45 -0
- data/{HISTORY → HISTORY.rdoc} +14 -1
- data/LICENSE +11 -8
- data/Manifest.txt +44 -0
- data/{README → README.rdoc} +18 -5
- data/Rakefile +20 -62
- data/ext/hitimes/{extconf.rb → c/extconf.rb} +3 -3
- 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.8/hitimes.so +0 -0
- data/lib/hitimes/1.9/hitimes.so +0 -0
- data/lib/hitimes/version.rb +1 -50
- data/spec/hitimes_spec.rb +14 -0
- data/spec/interval_spec.rb +24 -21
- data/spec/metric_spec.rb +8 -10
- data/spec/mutex_stats_spec.rb +8 -6
- data/spec/paths_spec.rb +1 -3
- data/spec/spec_helper.rb +7 -3
- data/spec/stats_spec.rb +26 -28
- data/spec/timed_metric_spec.rb +33 -33
- data/spec/timed_value_metric_spec.rb +45 -46
- data/spec/value_metric_spec.rb +21 -23
- data/spec/version_spec.rb +4 -30
- data/tasks/default.rake +267 -0
- data/tasks/extension.rake +31 -101
- data/tasks/this.rb +209 -0
- metadata +89 -88
- 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
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Hi there!
|
2
|
+
|
3
|
+
I see you are interested in contributing. That is wonderful. I love
|
4
|
+
contributions.
|
5
|
+
|
6
|
+
I guarantee that there are bugs in this software. And I guarantee that there is
|
7
|
+
a feature you want that is not in here yet. As such, any and all bugs reports
|
8
|
+
are gratefully accepted, bugfixes even more so. Helping out with bugs is the
|
9
|
+
easiest way to contribute.
|
10
|
+
|
11
|
+
|
12
|
+
## The Quick Version
|
13
|
+
|
14
|
+
* Have a [GitHub Account][].
|
15
|
+
* Search the [GitHub Issues][] and see if your issue already present. If so
|
16
|
+
add your comments, :thumbsup:, etc.
|
17
|
+
* Issue not there? Not a problem, open up a [new issue][].
|
18
|
+
* **Bug reports** please be as detailed as possible. Include:
|
19
|
+
* full ruby engine and version: `ruby -e 'puts RUBY_DESCRIPTION'`
|
20
|
+
* operating system and version
|
21
|
+
* version of hitimes `ruby -rubygems -e "require 'hitimes'; puts Hitimes::VERSION"`
|
22
|
+
* as much detail about the bug as possible so I can replicated it. Feel free
|
23
|
+
to link in a [gist][]
|
24
|
+
* **New Feature**
|
25
|
+
* What the new feature should do.
|
26
|
+
* What benefit the new feature brings to the project.
|
27
|
+
* Fork the [repo][].
|
28
|
+
* Create a new branch for your issue: `git checkout -b issue/my-issue`
|
29
|
+
* Lovingly craft your contribution:
|
30
|
+
* `rake develop` to get started, or if you prefer bundler `rake develop:using_bunder && bundle`.
|
31
|
+
* `rake test` to run tests
|
32
|
+
* Make sure that `rake test` passes. Its important, I said it twice.
|
33
|
+
* Add yourself to the contributors section below.
|
34
|
+
* Submit your [pull request][].
|
35
|
+
|
36
|
+
# Contributors
|
37
|
+
|
38
|
+
* Jeremy Hinegardner
|
39
|
+
|
40
|
+
[GitHub Account]: https://github.com/signup/free "GitHub Signup"
|
41
|
+
[GitHub Issues]: https://github.com/copiousfreetime/hitimes/issues "Hitimes Issues"
|
42
|
+
[new issue]: https://github.com/copiousfreetime/hitimes/issues/new "New Hitimes Issue"
|
43
|
+
[gist]: https://gist.github.com/ "New Gist"
|
44
|
+
[repo]: https://github.com/copiousfreetime/hitimes "hitimes Repo"
|
45
|
+
[pull request]: https://help.github.com/articles/using-pull-requests "Using Pull Requests"
|
data/{HISTORY → HISTORY.rdoc}
RENAMED
@@ -1,4 +1,17 @@
|
|
1
|
-
= Changelog
|
1
|
+
= Hitimes Changelog
|
2
|
+
|
3
|
+
== Version 1.2.0 2013-02-09
|
4
|
+
|
5
|
+
* Update dependencies
|
6
|
+
* Documentation cleanup
|
7
|
+
* Fix use of deprecated JRuby API in java extension
|
8
|
+
* Fix use of deprecated OSX system calls in C extension
|
9
|
+
* Make hitimes -w clean
|
10
|
+
* Fix ambiguity of calling duration on non-started Interval
|
11
|
+
* Use RbConfig instead of Config (eregon)
|
12
|
+
* Added Hitimes.measure
|
13
|
+
* Switch to using rake-compiler for cross compilation of gems
|
14
|
+
|
2
15
|
== Version 1.1.1 2010-09-04
|
3
16
|
|
4
17
|
* Remove the unnecessary dependencies that should be development dependencies
|
data/LICENSE
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
-
|
1
|
+
ISC LICENSE - http://opensource.org/licenses/isc-license.txt
|
2
|
+
|
3
|
+
Copyright (c) 2008-2012 Jeremy Hinegardner
|
2
4
|
|
3
5
|
Permission to use, copy, modify, and/or distribute this software for any
|
4
6
|
purpose with or without fee is hereby granted, provided that the above
|
5
7
|
copyright notice and this permission notice appear in all copies.
|
6
8
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
16
|
+
|
data/Manifest.txt
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
CONTRIBUTING.md
|
2
|
+
HISTORY.rdoc
|
3
|
+
LICENSE
|
4
|
+
Manifest.txt
|
5
|
+
README.rdoc
|
6
|
+
Rakefile
|
7
|
+
examples/benchmarks.rb
|
8
|
+
examples/stats.rb
|
9
|
+
ext/hitimes/c/extconf.rb
|
10
|
+
ext/hitimes/c/hitimes.c
|
11
|
+
ext/hitimes/c/hitimes_instant_clock_gettime.c
|
12
|
+
ext/hitimes/c/hitimes_instant_osx.c
|
13
|
+
ext/hitimes/c/hitimes_instant_windows.c
|
14
|
+
ext/hitimes/c/hitimes_interval.c
|
15
|
+
ext/hitimes/c/hitimes_interval.h
|
16
|
+
ext/hitimes/c/hitimes_stats.c
|
17
|
+
ext/hitimes/c/hitimes_stats.h
|
18
|
+
ext/hitimes/java/src/hitimes/Hitimes.java
|
19
|
+
ext/hitimes/java/src/hitimes/HitimesInterval.java
|
20
|
+
ext/hitimes/java/src/hitimes/HitimesService.java
|
21
|
+
ext/hitimes/java/src/hitimes/HitimesStats.java
|
22
|
+
lib/hitimes.rb
|
23
|
+
lib/hitimes/metric.rb
|
24
|
+
lib/hitimes/mutexed_stats.rb
|
25
|
+
lib/hitimes/paths.rb
|
26
|
+
lib/hitimes/stats.rb
|
27
|
+
lib/hitimes/timed_metric.rb
|
28
|
+
lib/hitimes/timed_value_metric.rb
|
29
|
+
lib/hitimes/value_metric.rb
|
30
|
+
lib/hitimes/version.rb
|
31
|
+
spec/hitimes_spec.rb
|
32
|
+
spec/interval_spec.rb
|
33
|
+
spec/metric_spec.rb
|
34
|
+
spec/mutex_stats_spec.rb
|
35
|
+
spec/paths_spec.rb
|
36
|
+
spec/spec_helper.rb
|
37
|
+
spec/stats_spec.rb
|
38
|
+
spec/timed_metric_spec.rb
|
39
|
+
spec/timed_value_metric_spec.rb
|
40
|
+
spec/value_metric_spec.rb
|
41
|
+
spec/version_spec.rb
|
42
|
+
tasks/default.rake
|
43
|
+
tasks/extension.rake
|
44
|
+
tasks/this.rb
|
data/{README → README.rdoc}
RENAMED
@@ -1,9 +1,9 @@
|
|
1
1
|
== hitimes
|
2
2
|
|
3
|
-
* Homepage[http://
|
4
|
-
* {
|
3
|
+
* Homepage[http://github.com/copiousfreetime/hitimes]
|
4
|
+
* {Github project}[http://github.com.org/copiousfreetime/hitimes]
|
5
5
|
* email jeremy at copiousfreetime dot org
|
6
|
-
* git clone url git://github.com/copiousfreetime/hitimes.git
|
6
|
+
* `git clone url git://github.com/copiousfreetime/hitimes.git`
|
7
7
|
|
8
8
|
== INSTALL
|
9
9
|
|
@@ -36,7 +36,7 @@ Use Hitimes::Interval to calculate only the duration of a block of code
|
|
36
36
|
# some operation ...
|
37
37
|
end
|
38
38
|
|
39
|
-
puts duration
|
39
|
+
puts duration
|
40
40
|
|
41
41
|
=== TimedMetric
|
42
42
|
|
@@ -114,13 +114,26 @@ Use a Hitimes::TimedValueMetric to calculate statistics about batches of samples
|
|
114
114
|
|
115
115
|
Read the HISTORY file.
|
116
116
|
|
117
|
+
== BUILDING FOR WINDOWS
|
118
|
+
|
119
|
+
{rake-compiler}(https://github.com/luislavena/rake-compiler) is use for building
|
120
|
+
the windows version. For me, on OSX to cross compile the process is:
|
121
|
+
|
122
|
+
% gem install rake-compiler # in each rvm instance, 1.8.7, 1.9.3
|
123
|
+
% rvm use 1.9.3@hitimes
|
124
|
+
% rake-compiler cross-ruby VERSION=1.9.3-p374 # or latest
|
125
|
+
% rvm use 1.8.7@hitimes
|
126
|
+
% rake-compiler cross-ruby VERSION=1.8.7-p371
|
127
|
+
|
128
|
+
# This only works via 1.8.7 at the current moment
|
129
|
+
% rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.3
|
117
130
|
== CREDITS
|
118
131
|
|
119
132
|
* Bruce Williams for suggesting the idea
|
120
133
|
|
121
134
|
== ISC License
|
122
135
|
|
123
|
-
Copyright (c) 2008 Jeremy Hinegardner
|
136
|
+
Copyright (c) 2008-2012 Jeremy Hinegardner
|
124
137
|
|
125
138
|
Permission to use, copy, modify, and/or distribute this software for any
|
126
139
|
purpose with or without fee is hereby granted, provided that the above
|
data/Rakefile
CHANGED
@@ -1,66 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# clobber tasks so that other tasks can utilize those constants if necessary
|
18
|
-
# This loads up the defaults for the whole project configuration
|
19
|
-
#-------------------------------------------------------------------------------
|
20
|
-
require 'rubygems'
|
21
|
-
require 'tasks/config.rb'
|
22
|
-
require 'rake/clean'
|
23
|
-
|
24
|
-
#-------------------------------------------------------------------------------
|
25
|
-
# Main configuration for the project, these overwrite the items that are in
|
26
|
-
# tasks/config.rb
|
27
|
-
#-------------------------------------------------------------------------------
|
28
|
-
require 'hitimes/version'
|
29
|
-
require 'hitimes/paths'
|
30
|
-
|
31
|
-
Configuration.for("project") {
|
32
|
-
name "hitimes"
|
33
|
-
version Hitimes::VERSION
|
34
|
-
author "Jeremy Hinegardner"
|
35
|
-
email "jeremy@copiousfreetime.org"
|
36
|
-
homepage "http://copiousfreetime.rubyforge.org/hitimes/"
|
37
|
-
}
|
38
|
-
|
39
|
-
#-------------------------------------------------------------------------------
|
40
|
-
# load up all the project tasks and setup the default task to be the
|
41
|
-
# test:default task.
|
42
|
-
#-------------------------------------------------------------------------------
|
43
|
-
Configuration.for("packaging").files.tasks.each do |tasklib|
|
44
|
-
import tasklib
|
1
|
+
# vim: syntax=ruby
|
2
|
+
load 'tasks/this.rb'
|
3
|
+
|
4
|
+
This.name = "hitimes"
|
5
|
+
This.author = "Jeremy Hinegardner"
|
6
|
+
This.email = "jeremy@copiousfreetime.org"
|
7
|
+
This.homepage = "http://github.com/copiousfreetime/#{ This.name }"
|
8
|
+
|
9
|
+
This.ruby_gemspec do |spec|
|
10
|
+
spec.add_development_dependency( 'rake' , '~> 10.0.3')
|
11
|
+
spec.add_development_dependency( 'rspec' , '~> 2.12.0' )
|
12
|
+
spec.add_development_dependency( 'rdoc' , '~> 3.12' )
|
13
|
+
spec.add_development_dependency( 'json' , '~> 1.7.6' )
|
14
|
+
spec.add_development_dependency( 'rake-compiler', '~> 0.8.1' )
|
15
|
+
|
16
|
+
spec.extensions.concat This.extension_conf_files
|
45
17
|
end
|
46
|
-
task :default => 'test:default'
|
47
18
|
|
48
|
-
|
49
|
-
|
50
|
-
# task to depend on all possible sub-level tasks that have a name like
|
51
|
-
# ':clobber' in other namespaces. This allows us to say:
|
52
|
-
#
|
53
|
-
# rake clobber
|
54
|
-
#
|
55
|
-
# and it will get everything.
|
56
|
-
#-------------------------------------------------------------------------------
|
57
|
-
Rake.application.load_imports
|
58
|
-
Rake.application.tasks.each do |t|
|
59
|
-
if t.name =~ /:clobber/ then
|
60
|
-
task :clobber => [t.name]
|
61
|
-
end
|
62
|
-
if t.name =~ /:clean/ then
|
63
|
-
task :clean => [t.name]
|
64
|
-
end
|
19
|
+
This.java_gemspec( This.ruby_gemspec ) do |spec|
|
20
|
+
spec.extensions.clear
|
65
21
|
end
|
66
22
|
|
23
|
+
load 'tasks/default.rake'
|
24
|
+
load 'tasks/extension.rake'
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'rbconfig'
|
2
2
|
require 'mkmf'
|
3
3
|
|
4
|
-
if
|
4
|
+
if RbConfig::CONFIG['host_os'] =~ /darwin/ then
|
5
5
|
$CFLAGS += " -DUSE_INSTANT_OSX=1 -Wall"
|
6
6
|
$LDFLAGS += " -framework CoreServices"
|
7
|
-
elsif
|
7
|
+
elsif RbConfig::CONFIG['host_os'] =~ /win32/ or RbConfig::CONFIG['host_os'] =~ /mingw/ then
|
8
8
|
$CFLAGS += " -DUSE_INSTANT_WINDOWS=1"
|
9
9
|
else
|
10
10
|
if have_library("rt", "clock_gettime") then
|
@@ -14,4 +14,4 @@ end
|
|
14
14
|
|
15
15
|
# put in a different location if on windows so we can have fat binaries
|
16
16
|
subdir = RUBY_VERSION.gsub(/\.\d$/,'')
|
17
|
-
create_makefile("hitimes/#{subdir}/
|
17
|
+
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 );
|