hitimes 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +13 -1
- data/HISTORY.md +6 -0
- data/README.md +78 -42
- data/Rakefile +1 -0
- data/ext/hitimes/c/extconf.rb +1 -1
- data/lib/hitimes.rb +14 -3
- data/lib/hitimes/version.rb +1 -1
- data/tasks/default.rake +1 -1
- data/tasks/this.rb +1 -1
- metadata +21 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 531b3a608c4a150a0d13e0312aeada44fdccb22e
|
4
|
+
data.tar.gz: adf7a50da04dde4b9d527da636ca4a19559071b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 340a336031ea96199111ec0ec432aad9016db68f06280d34b80b49000af427dcad0f0b7d125c7b9999c4a3bea2207401cb1be899f210c74d2963e15b335a4be4
|
7
|
+
data.tar.gz: c133b362a5d5384a1b7dff9cb681e2d3ebf2a85aa47ff4a6e156cb2f9c94b6f505156b043e7351a1bb104ff5318e901c0dc32a6afa76d80f4527d9e416647038
|
data/CONTRIBUTING.md
CHANGED
@@ -27,15 +27,27 @@ easiest way to contribute.
|
|
27
27
|
* Fork the [repo][].
|
28
28
|
* Create a new branch for your issue: `git checkout -b issue/my-issue`
|
29
29
|
* Lovingly craft your contribution:
|
30
|
-
* `rake develop` to get started
|
30
|
+
* `rake develop` to get started
|
31
31
|
* `rake test` to run tests
|
32
32
|
* Make sure that `rake test` passes. Its important, I said it twice.
|
33
33
|
* Add yourself to the contributors section below.
|
34
34
|
* Submit your [pull request][].
|
35
35
|
|
36
|
+
## Building Windows Binaries
|
37
|
+
|
38
|
+
This is done using https://github.com/rake-compiler/rake-compiler-dock
|
39
|
+
|
40
|
+
1. have VirtualBox installed
|
41
|
+
2. have Docker Machine installed (https://docs.docker.com/engine/installation/)
|
42
|
+
3. `gem install rake-compiler-dock`
|
43
|
+
4. `rake-compiler-dock` (this could take a while)
|
44
|
+
5. `bundle`
|
45
|
+
6. `rake cross native gem`
|
46
|
+
|
36
47
|
# Contributors
|
37
48
|
|
38
49
|
* Jeremy Hinegardner
|
50
|
+
* Wojciech Piekutowski
|
39
51
|
|
40
52
|
[GitHub Account]: https://github.com/signup/free "GitHub Signup"
|
41
53
|
[GitHub Issues]: https://github.com/copiousfreetime/hitimes/issues "Hitimes Issues"
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Hitimes Changelog
|
2
2
|
|
3
|
+
## Version 1.2.4 2016-05-01
|
4
|
+
|
5
|
+
* Fix finding the extension on ruby 2.1.10 (thanks @wpiekutowski)
|
6
|
+
* Add more readable load error (thanks @mbautin)
|
7
|
+
* Update README with what versions of ruby are supported.
|
8
|
+
|
3
9
|
## Version 1.2.3 2015-09-13
|
4
10
|
|
5
11
|
* Release new fatbinary version for windows
|
data/README.md
CHANGED
@@ -1,39 +1,52 @@
|
|
1
|
-
|
1
|
+
# Hitimes
|
2
|
+
|
3
|
+
A fast, high resolution timer library for recording peformance metrics.
|
2
4
|
|
3
5
|
* [Homepage](http://github.com/copiousfreetime/hitimes)
|
4
6
|
* [Github project](http://github.com.org/copiousfreetime/hitimes)
|
5
7
|
* email jeremy at copiousfreetime dot org
|
6
8
|
* `git clone url git://github.com/copiousfreetime/hitimes.git`
|
7
9
|
|
8
|
-
##
|
10
|
+
## Table of Contents
|
9
11
|
|
10
|
-
*
|
12
|
+
* [Requirements](#requirements)
|
13
|
+
* [Usage](#usage)
|
14
|
+
* [Contributing](#contributing)
|
15
|
+
* [Support](#support)
|
16
|
+
* [License](#license)
|
11
17
|
|
12
|
-
##
|
18
|
+
## Requirements
|
13
19
|
|
14
|
-
Hitimes
|
15
|
-
performance metrics. It uses the appropriate low method calls for each
|
16
|
-
system to get the highest granularity time increments possible.
|
20
|
+
Hitimes requires the following to run:
|
17
21
|
|
18
|
-
|
22
|
+
* Ruby
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Hitimes easiest to use when installed with `rubygems`:
|
27
|
+
|
28
|
+
```sh
|
29
|
+
gem install hitimes
|
30
|
+
```
|
31
|
+
|
32
|
+
Or as part of your bundler `Gemfile`:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
gem 'hitimes'
|
36
|
+
```
|
24
37
|
|
25
|
-
|
26
|
-
it will have a much higher granularity. It is definitely faster than
|
27
|
-
using `Process.times`.
|
38
|
+
You can load it with the standard ruby require statement.
|
28
39
|
|
29
|
-
|
40
|
+
```ruby
|
41
|
+
require 'hitimes'
|
42
|
+
```
|
30
43
|
|
31
44
|
### Interval
|
32
45
|
|
33
|
-
Use Hitimes::Interval to calculate only the duration of a block of code.
|
34
|
-
the time as seconds.
|
46
|
+
Use `Hitimes::Interval` to calculate only the duration of a block of code.
|
47
|
+
Returns the time as seconds.
|
35
48
|
|
36
|
-
```
|
49
|
+
```ruby
|
37
50
|
duration = Hitimes::Interval.measure do
|
38
51
|
1_000_000.times do |x|
|
39
52
|
2 + 2
|
@@ -45,15 +58,15 @@ puts duration # => 0.047414297 (seconds)
|
|
45
58
|
|
46
59
|
### TimedMetric
|
47
60
|
|
48
|
-
Use a Hitimes::TimedMetric to calculate statistics about an iterative operation
|
61
|
+
Use a `Hitimes::TimedMetric` to calculate statistics about an iterative operation
|
49
62
|
|
50
|
-
```
|
63
|
+
```ruby
|
51
64
|
timed_metric = Hitimes::TimedMetric.new('operation on items')
|
52
65
|
```
|
53
66
|
|
54
67
|
Explicitly use `start` and `stop`:
|
55
68
|
|
56
|
-
```
|
69
|
+
```ruby
|
57
70
|
collection.each do |item|
|
58
71
|
timed_metric.start
|
59
72
|
# .. do something with item
|
@@ -61,26 +74,26 @@ collection.each do |item|
|
|
61
74
|
end
|
62
75
|
```
|
63
76
|
|
64
|
-
Or use the block.
|
65
|
-
value of the block
|
77
|
+
Or use the block. In `TimedMetric` the return value of `measure` is the return
|
78
|
+
value of the block.
|
66
79
|
|
67
|
-
```
|
80
|
+
```ruby
|
68
81
|
collection.each do |item|
|
69
82
|
result_of_do_something = timed_metric.measure { do_something( item ) }
|
70
83
|
end
|
71
84
|
```
|
72
85
|
And then look at the stats
|
73
86
|
|
74
|
-
```
|
87
|
+
```ruby
|
75
88
|
puts timed_metric.mean
|
76
89
|
puts timed_metric.max
|
77
90
|
puts timed_metric.min
|
78
91
|
puts timed_metric.stddev
|
79
92
|
puts timed_metric.rate
|
80
93
|
```
|
81
|
-
### ValueMetric
|
94
|
+
### ValueMetric
|
82
95
|
|
83
|
-
Use a Hitimes::ValueMetric to calculate statistics about measured samples
|
96
|
+
Use a `Hitimes::ValueMetric` to calculate statistics about measured samples.
|
84
97
|
|
85
98
|
``` ruby
|
86
99
|
value_metric = Hitimes::ValueMetric.new( 'size of thing' )
|
@@ -99,7 +112,7 @@ puts value_metric.rate
|
|
99
112
|
|
100
113
|
### TimedValueMetric
|
101
114
|
|
102
|
-
Use a Hitimes::TimedValueMetric to calculate statistics about batches of samples
|
115
|
+
Use a `Hitimes::TimedValueMetric` to calculate statistics about batches of samples.
|
103
116
|
|
104
117
|
``` ruby
|
105
118
|
timed_value_metric = Hitimes::TimedValueMetric.new( 'batch times' )
|
@@ -123,28 +136,51 @@ puts timed_value_metric.value_stats.min
|
|
123
136
|
puts timed_value_metric.value_stats.stddev
|
124
137
|
```
|
125
138
|
|
126
|
-
|
139
|
+
### Implementation details
|
127
140
|
|
128
|
-
|
141
|
+
Hitimes use the appropriate low-level system call for each operating system to
|
142
|
+
get the highest granularity time increment possible. Generally this is
|
143
|
+
nanosecond resolution, or whatever the hardware chip in the CPU supports.
|
144
|
+
|
145
|
+
It currently supports any of the following systems:
|
129
146
|
|
130
|
-
|
147
|
+
* any system with the POSIX call `clock_gettime()`
|
148
|
+
* Mac OS X
|
149
|
+
* Windows
|
150
|
+
* JRuby
|
131
151
|
|
132
|
-
|
152
|
+
## Support
|
133
153
|
|
134
|
-
|
135
|
-
|
136
|
-
3. `gem install rake-compiler-dock`
|
137
|
-
4. `rake-compiler-dock`
|
138
|
-
5. `bundle`
|
139
|
-
6 `rake cross native gem`
|
154
|
+
Hitimes is supported on whatever versions of ruby are currently supported.
|
155
|
+
Hitimes also follows [semantic versioning](http://semver.org/).
|
140
156
|
|
141
|
-
|
157
|
+
The current officially supported versions of Ruby are:
|
158
|
+
|
159
|
+
* MRI Ruby 2.2, 2.3
|
160
|
+
* JRuby 1.7.25, 9.0.5.0
|
161
|
+
|
162
|
+
Unofficially supported versions, they have been supported in the past when they
|
163
|
+
were the primary rubies around. In all likelihood they still work, but are not
|
164
|
+
supported.
|
165
|
+
|
166
|
+
* MRI Ruby - everything from 1.8.7 to 2.1
|
167
|
+
* JRuby - I think everything back to 1.4
|
168
|
+
* Rubinius
|
169
|
+
|
170
|
+
## Contributing
|
171
|
+
|
172
|
+
Please read the [CONTRIBUTING.md](CONTRIBUTING.md)
|
173
|
+
|
174
|
+
## Credits
|
142
175
|
|
143
176
|
* [Bruce Williams](https://github.com/bruce) for suggesting the idea
|
144
177
|
|
145
|
-
##
|
178
|
+
## License
|
179
|
+
|
180
|
+
Hitimes is licensed under the [ISC](https://opensource.org/licenses/ISC)
|
181
|
+
license.
|
146
182
|
|
147
|
-
Copyright (c) 2008-
|
183
|
+
Copyright (c) 2008-2016 Jeremy Hinegardner
|
148
184
|
|
149
185
|
Permission to use, copy, modify, and/or distribute this software for any
|
150
186
|
purpose with or without fee is hereby granted, provided that the above
|
data/Rakefile
CHANGED
@@ -12,6 +12,7 @@ This.ruby_gemspec do |spec|
|
|
12
12
|
spec.add_development_dependency( 'rdoc' , '~> 4.2' )
|
13
13
|
spec.add_development_dependency( 'json' , '~> 1.8' )
|
14
14
|
spec.add_development_dependency( 'rake-compiler', '~> 0.9' )
|
15
|
+
spec.add_development_dependency( 'rake-compiler-dock', '~> 0.4' )
|
15
16
|
spec.add_development_dependency( 'simplecov' , '~> 0.9' )
|
16
17
|
|
17
18
|
spec.extensions.concat This.extension_conf_files
|
data/ext/hitimes/c/extconf.rb
CHANGED
data/lib/hitimes.rb
CHANGED
@@ -31,19 +31,30 @@ require 'hitimes/version'
|
|
31
31
|
# this is the method recommended by rake-compiler
|
32
32
|
|
33
33
|
attempts = [
|
34
|
-
"hitimes/#{RUBY_VERSION.sub(/\.\d
|
34
|
+
"hitimes/#{RUBY_VERSION.sub(/\.\d+$/,'')}/hitimes",
|
35
35
|
"hitimes/hitimes"
|
36
36
|
]
|
37
37
|
loaded = false
|
38
38
|
|
39
|
+
path_exceptions = []
|
39
40
|
attempts.each do |path|
|
40
41
|
begin
|
41
42
|
require path
|
42
43
|
loaded = true
|
43
|
-
|
44
|
+
break
|
45
|
+
rescue LoadError => load_error
|
46
|
+
full_path = File.expand_path(path)
|
47
|
+
path_exceptions << [ full_path, load_error.message ]
|
44
48
|
end
|
45
49
|
end
|
46
|
-
|
50
|
+
|
51
|
+
if !loaded then
|
52
|
+
msg = ["Unable to find binary extension, was hitimes installed correctly? The following paths were tried."]
|
53
|
+
path_exceptions.each do |path, message|
|
54
|
+
msg << "#{path} : #{message}"
|
55
|
+
end
|
56
|
+
raise LoadError, msg.join("\n")
|
57
|
+
end
|
47
58
|
|
48
59
|
require 'hitimes/stats'
|
49
60
|
require 'hitimes/mutexed_stats'
|
data/lib/hitimes/version.rb
CHANGED
data/tasks/default.rake
CHANGED
data/tasks/this.rb
CHANGED
@@ -180,7 +180,7 @@ class ThisProject
|
|
180
180
|
|
181
181
|
# Internal: Return the DESCRIPTION section of the README.rdoc file
|
182
182
|
def description_section
|
183
|
-
section_of( 'README.md', '
|
183
|
+
section_of( 'README.md', 'Hitimes')
|
184
184
|
end
|
185
185
|
|
186
186
|
# Internal: Return the summary text from the README
|
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.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Hinegardner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.9'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake-compiler-dock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.4'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: simplecov
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,12 +108,9 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0.9'
|
97
|
-
description:
|
98
|
-
|
99
|
-
|
100
|
-
systems: * any system with the POSIX call `clock_gettime()` * Mac OS X * Windows
|
101
|
-
* JRuby Using Hitimes can be faster than using a series of `Time.new` calls, and
|
102
|
-
it will have a much higher granularity. It is definitely faster than using `Process.times`.'
|
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`
|
103
114
|
email: jeremy@copiousfreetime.org
|
104
115
|
executables: []
|
105
116
|
extensions:
|
@@ -178,12 +189,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
189
|
version: '0'
|
179
190
|
requirements: []
|
180
191
|
rubyforge_project:
|
181
|
-
rubygems_version: 2.4
|
192
|
+
rubygems_version: 2.6.4
|
182
193
|
signing_key:
|
183
194
|
specification_version: 4
|
184
|
-
summary:
|
185
|
-
metrics. It uses the appropriate low method calls for each system to get the highest
|
186
|
-
granularity time increments possible.
|
195
|
+
summary: A fast, high resolution timer library for recording peformance metrics.
|
187
196
|
test_files:
|
188
197
|
- spec/hitimes_spec.rb
|
189
198
|
- spec/interval_spec.rb
|