hitimes 1.2.0-java → 1.2.1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/{HISTORY.rdoc → HISTORY.md} +25 -19
- data/Manifest.txt +2 -2
- data/README.md +163 -0
- data/Rakefile +4 -4
- data/lib/hitimes/hitimes.jar +0 -0
- data/lib/hitimes/version.rb +1 -1
- data/tasks/default.rake +6 -2
- data/tasks/extension.rake +1 -1
- data/tasks/this.rb +4 -4
- metadata +19 -19
- data/README.rdoc +0 -148
data/{HISTORY.rdoc → HISTORY.md}
RENAMED
@@ -1,6 +1,12 @@
|
|
1
|
-
|
1
|
+
# Hitimes Changelog
|
2
2
|
|
3
|
-
|
3
|
+
## Version 1.2.1 2013-03-12
|
4
|
+
|
5
|
+
* Update dependencies
|
6
|
+
* Ruby 2.0 fixes
|
7
|
+
* Switch to Markdown, Yeah RDoc 4.0!
|
8
|
+
|
9
|
+
## Version 1.2.0 2013-02-09
|
4
10
|
|
5
11
|
* Update dependencies
|
6
12
|
* Documentation cleanup
|
@@ -12,75 +18,75 @@
|
|
12
18
|
* Added Hitimes.measure
|
13
19
|
* Switch to using rake-compiler for cross compilation of gems
|
14
20
|
|
15
|
-
|
21
|
+
## Version 1.1.1 2010-09-04
|
16
22
|
|
17
23
|
* Remove the unnecessary dependencies that should be development dependencies
|
18
24
|
|
19
|
-
|
25
|
+
## Version 1.1.0 2010-07-28
|
20
26
|
|
21
27
|
* Add a pure java extension so hitimes may be used in jruby with the same API
|
22
28
|
|
23
|
-
|
29
|
+
## Version 1.0.5 2010-07-20
|
24
30
|
|
25
31
|
* Fix 'circular require considered harmful' warnings in 1.9.x (reported by Roger Pack)
|
26
32
|
* Fix 'method redefined' warnings in 1.9.x (reported by Roger Pack)
|
27
33
|
|
28
|
-
|
34
|
+
## Version 1.0.4 2009-08-01
|
29
35
|
|
30
36
|
* Add in support for x86-mingw32 gem
|
31
37
|
* Add version subdirectory for extension on all platforms
|
32
38
|
|
33
|
-
|
39
|
+
## Version 1.0.3 2009-06-28
|
34
40
|
|
35
41
|
* Fix bug with time.h on linode (reported by Roger Pack)
|
36
42
|
* Fix potential garbage collection issue with Interval class
|
37
43
|
* Windows gem is now a fat binary to support installing in 1.8 or 1.9 from the
|
38
44
|
same gem
|
39
45
|
|
40
|
-
|
46
|
+
## Version 1.0.1 2009-06-12
|
41
47
|
|
42
48
|
* Fix examples
|
43
49
|
* performance tuning, new Hitimes::Metric derived classes are faster than old Timer class
|
44
50
|
|
45
|
-
|
51
|
+
## Version 1.0.0 2009-06-12
|
46
52
|
|
47
53
|
* Major version bump with complete refactor of the metric collection API
|
48
54
|
* 3 types of metrics now instead of just 1 Timer
|
49
|
-
|
50
|
-
|
51
|
-
|
55
|
+
* Hitimes::ValueMetric
|
56
|
+
* Hitimes::TimedMetric
|
57
|
+
* Hitimes::TimedValueMetric
|
52
58
|
* The ability to convert all metrics #to_hash
|
53
59
|
* Updated documentation with examples using each metric type
|
54
60
|
|
55
|
-
|
61
|
+
## Version 0.4.1 2009-02-19
|
56
62
|
|
57
63
|
* change to ISC License
|
58
64
|
* fix bug in compilation on gentoo
|
59
65
|
|
60
|
-
|
66
|
+
## Version 0.4.0 2008-12-20
|
61
67
|
|
62
68
|
* Added new stat 'rate'
|
63
69
|
* Added new stat method to_hash
|
64
70
|
* Added Hitimes::MutexedStats class for threadsafe stats collection
|
65
|
-
|
71
|
+
- not needed when used in MRI 1.8.x
|
66
72
|
* remove stale dependency on mkrf
|
67
73
|
|
68
|
-
|
74
|
+
## Version 0.3.0
|
69
75
|
|
70
76
|
* switched to extconf for building extensions
|
71
77
|
* first release of windows binary gem
|
72
78
|
* reverted back to normal rdoc
|
73
79
|
|
74
|
-
|
80
|
+
## Version 0.2.1
|
75
81
|
|
76
82
|
* added Timer#rate method
|
77
83
|
* switched to darkfish rdoc
|
78
84
|
|
79
|
-
|
85
|
+
## Version 0.2.0
|
80
86
|
|
81
87
|
* Performance improvements
|
82
88
|
* Added Hitimes::Stats class
|
83
89
|
|
84
|
-
|
90
|
+
## Version 0.1.0
|
85
91
|
|
86
92
|
* Initial completion
|
data/Manifest.txt
CHANGED
data/README.md
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
## hitimes
|
2
|
+
|
3
|
+
* [Homepage](http://github.com/copiousfreetime/hitimes)
|
4
|
+
* [Github project](http://github.com.org/copiousfreetime/hitimes)
|
5
|
+
* email jeremy at copiousfreetime dot org
|
6
|
+
* `git clone url git://github.com/copiousfreetime/hitimes.git`
|
7
|
+
|
8
|
+
## INSTALL
|
9
|
+
|
10
|
+
* `gem install hitimes`
|
11
|
+
|
12
|
+
## DESCRIPTION
|
13
|
+
|
14
|
+
Hitimes is a fast, high resolution timer library for recording
|
15
|
+
performance metrics. It uses the appropriate low method calls for each
|
16
|
+
system to get the highest granularity time increments possible.
|
17
|
+
|
18
|
+
It currently supports any of the following systems:
|
19
|
+
|
20
|
+
* any system with the POSIX call `clock_gettime()`
|
21
|
+
* Mac OS X
|
22
|
+
* Windows
|
23
|
+
* JRuby
|
24
|
+
|
25
|
+
Using Hitimes can be faster than using a series of `Time.new` calls, and
|
26
|
+
it will have a much higher granularity. It is definitely faster than
|
27
|
+
using `Process.times`.
|
28
|
+
|
29
|
+
## SYNOPSIS
|
30
|
+
|
31
|
+
### Interval
|
32
|
+
|
33
|
+
Use Hitimes::Interval to calculate only the duration of a block of code
|
34
|
+
|
35
|
+
``` ruby
|
36
|
+
duration = Hitimes::Interval.measure do
|
37
|
+
# some operation ...
|
38
|
+
end
|
39
|
+
|
40
|
+
puts duration
|
41
|
+
```
|
42
|
+
|
43
|
+
### TimedMetric
|
44
|
+
|
45
|
+
Use a Hitimes::TimedMetric to calculate statistics about an iterative operation
|
46
|
+
|
47
|
+
``` ruby
|
48
|
+
timed_metric = Hitimes::TimedMetric.new('operation on items')
|
49
|
+
```
|
50
|
+
|
51
|
+
Explicitly use `start` and `stop`:
|
52
|
+
|
53
|
+
``` ruby
|
54
|
+
collection.each do |item|
|
55
|
+
timed_metric.start
|
56
|
+
# .. do something with item
|
57
|
+
timed_metric.stop
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
Or use the block. In TimedMetric the return value of +measure+ is the return
|
62
|
+
value of the block
|
63
|
+
|
64
|
+
``` ruby
|
65
|
+
collection.each do |item|
|
66
|
+
result_of_do_something = timed_metric.measure { do_something( item ) }
|
67
|
+
end
|
68
|
+
```
|
69
|
+
And then look at the stats
|
70
|
+
|
71
|
+
``` ruby
|
72
|
+
puts timed_metric.mean
|
73
|
+
puts timed_metric.max
|
74
|
+
puts timed_metric.min
|
75
|
+
puts timed_metric.stddev
|
76
|
+
puts timed_metric.rate
|
77
|
+
```
|
78
|
+
### ValueMetric
|
79
|
+
|
80
|
+
Use a Hitimes::ValueMetric to calculate statistics about measured samples
|
81
|
+
|
82
|
+
``` ruby
|
83
|
+
value_metric = Hitimes::ValueMetric.new( 'size of thing' )
|
84
|
+
loop do
|
85
|
+
# ... do stuff changing sizes of 'thing'
|
86
|
+
value_metric.measure( thing.size )
|
87
|
+
# ... do other stuff that may change size of thing
|
88
|
+
end
|
89
|
+
|
90
|
+
puts value_metric.mean
|
91
|
+
puts value_metric.max
|
92
|
+
puts value_metric.min
|
93
|
+
puts value_metric.stddev
|
94
|
+
puts value_metric.rate
|
95
|
+
```
|
96
|
+
|
97
|
+
### TimedValueMetric
|
98
|
+
|
99
|
+
Use a Hitimes::TimedValueMetric to calculate statistics about batches of samples
|
100
|
+
|
101
|
+
``` ruby
|
102
|
+
timed_value_metric = Hitimes::TimedValueMetric.new( 'batch times' )
|
103
|
+
loop do
|
104
|
+
batch = ... # get a batch of things
|
105
|
+
timed_value_metric.start
|
106
|
+
# .. do something with batch
|
107
|
+
timed_value_metric.stop( batch.size )
|
108
|
+
end
|
109
|
+
|
110
|
+
puts timed_value_metric.rate
|
111
|
+
|
112
|
+
puts timed_value_metric.timed_stats.mean
|
113
|
+
puts timed_value_metric.timed_stats.max
|
114
|
+
puts timed_value_metric.timed_stats.min
|
115
|
+
puts timed_value_metric.timed_stats.stddev
|
116
|
+
|
117
|
+
puts timed_value_metric.value_stats.mean
|
118
|
+
puts timed_value_metric.value_stats.max
|
119
|
+
puts timed_value_metric.value_stats.min
|
120
|
+
puts timed_value_metric.value_stats.stddev
|
121
|
+
```
|
122
|
+
|
123
|
+
## CHANGES
|
124
|
+
|
125
|
+
Read the HISTORY.md file.
|
126
|
+
|
127
|
+
## BUILDING FOR WINDOWS
|
128
|
+
|
129
|
+
[rake-compiler](https://github.com/luislavena/rake-compiler) is use for building
|
130
|
+
the windows version. For me, on OSX to cross compile the process is:
|
131
|
+
|
132
|
+
```
|
133
|
+
% gem install rake-compiler # in each rvm instance, 1.8.7, 1.9.3
|
134
|
+
% rvm use 2.0.0@hitimes
|
135
|
+
% rake-compiler cross-ruby VERSION=2.0.0-p0 # or latest
|
136
|
+
% rvm use 1.9.3@hitimes
|
137
|
+
% rake-compiler cross-ruby VERSION=1.9.3-p374 # or latest
|
138
|
+
% rvm use 1.8.7@hitimes
|
139
|
+
% rake-compiler cross-ruby VERSION=1.8.7-p371
|
140
|
+
|
141
|
+
# This only works via 1.8.7 at the current moment
|
142
|
+
% rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.3:2.0.0
|
143
|
+
```
|
144
|
+
|
145
|
+
## CREDITS
|
146
|
+
|
147
|
+
* [Bruce Williams](https://github.com/bruce) for suggesting the idea
|
148
|
+
|
149
|
+
## ISC License
|
150
|
+
|
151
|
+
Copyright (c) 2008-2012 Jeremy Hinegardner
|
152
|
+
|
153
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
154
|
+
purpose with or without fee is hereby granted, provided that the above
|
155
|
+
copyright notice and this permission notice appear in all copies.
|
156
|
+
|
157
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
158
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
159
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
160
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
161
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
162
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
163
|
+
PERFORMANCE OF THIS SOFTWARE.
|
data/Rakefile
CHANGED
@@ -8,10 +8,10 @@ This.homepage = "http://github.com/copiousfreetime/#{ This.name }"
|
|
8
8
|
|
9
9
|
This.ruby_gemspec do |spec|
|
10
10
|
spec.add_development_dependency( 'rake' , '~> 10.0.3')
|
11
|
-
spec.add_development_dependency( 'rspec' , '~> 2.
|
12
|
-
spec.add_development_dependency( 'rdoc' , '~>
|
13
|
-
spec.add_development_dependency( 'json' , '~> 1.7.
|
14
|
-
spec.add_development_dependency( 'rake-compiler', '~> 0.8.
|
11
|
+
spec.add_development_dependency( 'rspec' , '~> 2.13.0' )
|
12
|
+
spec.add_development_dependency( 'rdoc' , '~> 4.0' )
|
13
|
+
spec.add_development_dependency( 'json' , '~> 1.7.7' )
|
14
|
+
spec.add_development_dependency( 'rake-compiler', '~> 0.8.3' )
|
15
15
|
|
16
16
|
spec.extensions.concat This.extension_conf_files
|
17
17
|
end
|
data/lib/hitimes/hitimes.jar
CHANGED
Binary file
|
data/lib/hitimes/version.rb
CHANGED
data/tasks/default.rake
CHANGED
@@ -74,9 +74,10 @@ begin
|
|
74
74
|
RDoc::Task.new do |t|
|
75
75
|
t.markup = 'tomdoc'
|
76
76
|
t.rdoc_dir = 'doc'
|
77
|
-
t.main = 'README.
|
77
|
+
t.main = 'README.md'
|
78
78
|
t.title = "#{This.name} #{This.version}"
|
79
|
-
t.rdoc_files.include( '*.rdoc', '
|
79
|
+
t.rdoc_files.include( FileList['*.{rdoc,md,txt}'], FileList['ext/**/*.c'],
|
80
|
+
FileList['lib/**/*.rb'] )
|
80
81
|
end
|
81
82
|
rescue LoadError => le
|
82
83
|
This.task_warning( 'rdoc' )
|
@@ -228,6 +229,9 @@ end
|
|
228
229
|
# the gemspec is also a dev artifact and should not be kept around.
|
229
230
|
CLOBBER << This.gemspec_file.to_s
|
230
231
|
|
232
|
+
# .rbc files from ruby 2.0
|
233
|
+
CLOBBER << FileList["**/*.rbc"]
|
234
|
+
|
231
235
|
# The standard gem packaging task, everyone has it.
|
232
236
|
require 'rubygems/package_task'
|
233
237
|
Gem::PackageTask.new( This.platform_gemspec ) do
|
data/tasks/extension.rake
CHANGED
data/tasks/this.rb
CHANGED
@@ -54,7 +54,7 @@ class ThisProject
|
|
54
54
|
#
|
55
55
|
# Retuns the text of the section as an array of paragrphs.
|
56
56
|
def section_of( file, section_name )
|
57
|
-
re =
|
57
|
+
re = /^[=#]+ (.*)$/
|
58
58
|
sectional = project_path( file )
|
59
59
|
parts = sectional.read.split( re )[1..-1]
|
60
60
|
parts.map! { |p| p.strip }
|
@@ -137,8 +137,8 @@ class ThisProject
|
|
137
137
|
spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
|
138
138
|
spec.test_files = spec.files.grep(/^spec/)
|
139
139
|
|
140
|
-
spec.extra_rdoc_files += spec.files.grep(/(txt|rdoc)$/)
|
141
|
-
spec.rdoc_options = [ "--main" , 'README.
|
140
|
+
spec.extra_rdoc_files += spec.files.grep(/(txt|rdoc|md)$/)
|
141
|
+
spec.rdoc_options = [ "--main" , 'README.md',
|
142
142
|
"--markup", "tomdoc" ]
|
143
143
|
end
|
144
144
|
end
|
@@ -187,7 +187,7 @@ class ThisProject
|
|
187
187
|
|
188
188
|
# Internal: Return the DESCRIPTION section of the README.rdoc file
|
189
189
|
def description_section
|
190
|
-
section_of( 'README.
|
190
|
+
section_of( 'README.md', 'DESCRIPTION')
|
191
191
|
end
|
192
192
|
|
193
193
|
# Internal: Return the summary text from the README
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hitimes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.1
|
4
5
|
prerelease:
|
5
|
-
version: 1.2.0
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Jeremy Hinegardner
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -33,13 +33,13 @@ dependencies:
|
|
33
33
|
requirements:
|
34
34
|
- - "~>"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 2.
|
36
|
+
version: 2.13.0
|
37
37
|
none: false
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 2.
|
42
|
+
version: 2.13.0
|
43
43
|
none: false
|
44
44
|
prerelease: false
|
45
45
|
type: :development
|
@@ -49,13 +49,13 @@ dependencies:
|
|
49
49
|
requirements:
|
50
50
|
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '4.0'
|
53
53
|
none: false
|
54
54
|
requirement: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
56
|
- - "~>"
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version: '
|
58
|
+
version: '4.0'
|
59
59
|
none: false
|
60
60
|
prerelease: false
|
61
61
|
type: :development
|
@@ -65,13 +65,13 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.7.
|
68
|
+
version: 1.7.7
|
69
69
|
none: false
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 1.7.
|
74
|
+
version: 1.7.7
|
75
75
|
none: false
|
76
76
|
prerelease: false
|
77
77
|
type: :development
|
@@ -81,36 +81,36 @@ dependencies:
|
|
81
81
|
requirements:
|
82
82
|
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: 0.8.
|
84
|
+
version: 0.8.3
|
85
85
|
none: false
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.8.
|
90
|
+
version: 0.8.3
|
91
91
|
none: false
|
92
92
|
prerelease: false
|
93
93
|
type: :development
|
94
94
|
description: ! 'Hitimes is a fast, high resolution timer library for recording performance
|
95
95
|
metrics. It uses the appropriate low method calls for each system to get the highest
|
96
96
|
granularity time increments possible. It currently supports any of the following
|
97
|
-
systems: * any system with the POSIX call
|
98
|
-
|
99
|
-
|
100
|
-
+Process.times+.'
|
97
|
+
systems: * any system with the POSIX call `clock_gettime()` * Mac OS X * Windows
|
98
|
+
* JRuby Using Hitimes can be faster than using a series of `Time.new` calls, and
|
99
|
+
it will have a much higher granularity. It is definitely faster than using `Process.times`.'
|
101
100
|
email: jeremy@copiousfreetime.org
|
102
101
|
executables: []
|
103
102
|
extensions: []
|
104
103
|
extra_rdoc_files:
|
105
|
-
-
|
104
|
+
- CONTRIBUTING.md
|
105
|
+
- HISTORY.md
|
106
106
|
- Manifest.txt
|
107
|
-
- README.
|
107
|
+
- README.md
|
108
108
|
files:
|
109
109
|
- CONTRIBUTING.md
|
110
|
-
- HISTORY.
|
110
|
+
- HISTORY.md
|
111
111
|
- LICENSE
|
112
112
|
- Manifest.txt
|
113
|
-
- README.
|
113
|
+
- README.md
|
114
114
|
- Rakefile
|
115
115
|
- examples/benchmarks.rb
|
116
116
|
- examples/stats.rb
|
@@ -156,7 +156,7 @@ licenses: []
|
|
156
156
|
post_install_message:
|
157
157
|
rdoc_options:
|
158
158
|
- "--main"
|
159
|
-
- README.
|
159
|
+
- README.md
|
160
160
|
- "--markup"
|
161
161
|
- tomdoc
|
162
162
|
require_paths:
|
data/README.rdoc
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
== hitimes
|
2
|
-
|
3
|
-
* Homepage[http://github.com/copiousfreetime/hitimes]
|
4
|
-
* {Github project}[http://github.com.org/copiousfreetime/hitimes]
|
5
|
-
* email jeremy at copiousfreetime dot org
|
6
|
-
* `git clone url git://github.com/copiousfreetime/hitimes.git`
|
7
|
-
|
8
|
-
== INSTALL
|
9
|
-
|
10
|
-
* gem install hitimes
|
11
|
-
|
12
|
-
== DESCRIPTION
|
13
|
-
|
14
|
-
Hitimes is a fast, high resolution timer library for recording
|
15
|
-
performance metrics. It uses the appropriate low method calls for each
|
16
|
-
system to get the highest granularity time increments possible.
|
17
|
-
|
18
|
-
It currently supports any of the following systems:
|
19
|
-
|
20
|
-
* any system with the POSIX call <tt>clock_gettime()</tt>,
|
21
|
-
* Mac OS X
|
22
|
-
* Windows
|
23
|
-
* JRuby
|
24
|
-
|
25
|
-
Using Hitimes can be faster than using a series of +Time.new+ calls, and
|
26
|
-
it will have a much higher granularity. It is definitely faster than
|
27
|
-
using +Process.times+.
|
28
|
-
|
29
|
-
== SYNOPSIS
|
30
|
-
|
31
|
-
=== Interval
|
32
|
-
|
33
|
-
Use Hitimes::Interval to calculate only the duration of a block of code
|
34
|
-
|
35
|
-
duration = Hitimes::Interval.measure do
|
36
|
-
# some operation ...
|
37
|
-
end
|
38
|
-
|
39
|
-
puts duration
|
40
|
-
|
41
|
-
=== TimedMetric
|
42
|
-
|
43
|
-
Use a Hitimes::TimedMetric to calculate statistics about an iterative operation
|
44
|
-
|
45
|
-
timed_metric = Hitimes::TimedMetric.new('operation on items')
|
46
|
-
|
47
|
-
Explicitly use +start+ and +stop+:
|
48
|
-
|
49
|
-
collection.each do |item|
|
50
|
-
timed_metric.start
|
51
|
-
# .. do something with item
|
52
|
-
timed_metric.stop
|
53
|
-
end
|
54
|
-
|
55
|
-
Or use the block. In TimedMetric the return value of +measure+ is the return
|
56
|
-
value of the block
|
57
|
-
|
58
|
-
collection.each do |item|
|
59
|
-
result_of_do_something = timed_metric.measure { do_something( item ) }
|
60
|
-
end
|
61
|
-
|
62
|
-
And then look at the stats
|
63
|
-
|
64
|
-
puts timed_metric.mean
|
65
|
-
puts timed_metric.max
|
66
|
-
puts timed_metric.min
|
67
|
-
puts timed_metric.stddev
|
68
|
-
puts timed_metric.rate
|
69
|
-
|
70
|
-
=== ValueMetric
|
71
|
-
|
72
|
-
Use a Hitimes::ValueMetric to calculate statistics about measured samples
|
73
|
-
|
74
|
-
value_metric = Hitimes::ValueMetric.new( 'size of thing' )
|
75
|
-
loop do
|
76
|
-
# ... do stuff changing sizes of 'thing'
|
77
|
-
value_metric.measure( thing.size )
|
78
|
-
# ... do other stuff that may change size of thing
|
79
|
-
end
|
80
|
-
|
81
|
-
puts value_metric.mean
|
82
|
-
puts value_metric.max
|
83
|
-
puts value_metric.min
|
84
|
-
puts value_metric.stddev
|
85
|
-
puts value_metric.rate
|
86
|
-
|
87
|
-
|
88
|
-
=== TimedValueMetric
|
89
|
-
|
90
|
-
Use a Hitimes::TimedValueMetric to calculate statistics about batches of samples
|
91
|
-
|
92
|
-
timed_value_metric = Hitimes::TimedValueMetric.new( 'batch times' )
|
93
|
-
loop do
|
94
|
-
batch = ... # get a batch of things
|
95
|
-
timed_value_metric.start
|
96
|
-
# .. do something with batch
|
97
|
-
timed_value_metric.stop( batch.size )
|
98
|
-
end
|
99
|
-
|
100
|
-
puts timed_value_metric.rate
|
101
|
-
|
102
|
-
puts timed_value_metric.timed_stats.mean
|
103
|
-
puts timed_value_metric.timed_stats.max
|
104
|
-
puts timed_value_metric.timed_stats.min
|
105
|
-
puts timed_value_metric.timed_stats.stddev
|
106
|
-
|
107
|
-
puts timed_value_metric.value_stats.mean
|
108
|
-
puts timed_value_metric.value_stats.max
|
109
|
-
puts timed_value_metric.value_stats.min
|
110
|
-
puts timed_value_metric.value_stats.stddev
|
111
|
-
|
112
|
-
|
113
|
-
== CHANGES
|
114
|
-
|
115
|
-
Read the HISTORY file.
|
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
|
130
|
-
== CREDITS
|
131
|
-
|
132
|
-
* Bruce Williams for suggesting the idea
|
133
|
-
|
134
|
-
== ISC License
|
135
|
-
|
136
|
-
Copyright (c) 2008-2012 Jeremy Hinegardner
|
137
|
-
|
138
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
139
|
-
purpose with or without fee is hereby granted, provided that the above
|
140
|
-
copyright notice and this permission notice appear in all copies.
|
141
|
-
|
142
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
143
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
144
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
145
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
146
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
147
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
148
|
-
PERFORMANCE OF THIS SOFTWARE.
|