hitimes 0.4.1-x86-mswin32-60 → 1.0.0-x86-mswin32-60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY +10 -0
- data/README +74 -14
- data/ext/hitimes_interval.c +6 -3
- data/ext/hitimes_stats.c +31 -8
- data/gemspec.rb +4 -2
- data/lib/hitimes.rb +5 -1
- data/lib/hitimes/metric.rb +74 -0
- data/lib/hitimes/stats.rb +26 -1
- data/lib/hitimes/timed_metric.rb +181 -0
- data/lib/hitimes/timed_value_metric.rb +240 -0
- data/lib/hitimes/value_metric.rb +69 -0
- data/lib/hitimes/version.rb +23 -8
- data/lib/hitimes_ext.so +0 -0
- data/spec/metric_spec.rb +30 -0
- data/spec/stats_spec.rb +30 -2
- data/spec/timed_metric_spec.rb +155 -0
- data/spec/timed_value_metric_spec.rb +172 -0
- data/spec/value_metric_spec.rb +110 -0
- data/spec/version_spec.rb +6 -0
- data/tasks/config.rb +1 -1
- metadata +27 -8
- data/lib/hitimes/timer.rb +0 -223
- data/spec/timer_spec.rb +0 -105
data/tasks/config.rb
CHANGED
@@ -83,7 +83,7 @@ Configuration.for('rdoc') {
|
|
83
83
|
files Configuration.for('packaging').files.rdoc
|
84
84
|
main_page files.first
|
85
85
|
title Configuration.for('project').name
|
86
|
-
options %w[ --line-numbers --inline-source ]
|
86
|
+
options %w[ --line-numbers --inline-source ]
|
87
87
|
output_dir "doc"
|
88
88
|
}
|
89
89
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hitimes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: x86-mswin32-60
|
6
6
|
authors:
|
7
7
|
- Jeremy Hinegardner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-12 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- -
|
21
|
+
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 0.8.1
|
24
24
|
version:
|
@@ -28,11 +28,21 @@ dependencies:
|
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.0.5
|
34
34
|
version:
|
35
|
-
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: json
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.1.3
|
44
|
+
version:
|
45
|
+
description: "Hitimes is a fast, high resolution timer library for recording performance metrics. It uses the appropriate C method calls for each system to get the highest granularity time increments possible. It currently supports any of the following systems: * any system with the POSIX call <tt>clock_gettime()</tt>, * Mac OS X * Windows Using Hitimes can be faster than using a series of +Time.new+ calls, and it will have a much higher granularity. It is definitely faster than using +Process.times+."
|
36
46
|
email: jeremy@copiousfreetime.org
|
37
47
|
executables: []
|
38
48
|
|
@@ -42,10 +52,13 @@ extra_rdoc_files:
|
|
42
52
|
- README
|
43
53
|
- HISTORY
|
44
54
|
- LICENSE
|
55
|
+
- lib/hitimes/metric.rb
|
45
56
|
- lib/hitimes/mutexed_stats.rb
|
46
57
|
- lib/hitimes/paths.rb
|
47
58
|
- lib/hitimes/stats.rb
|
48
|
-
- lib/hitimes/
|
59
|
+
- lib/hitimes/timed_metric.rb
|
60
|
+
- lib/hitimes/timed_value_metric.rb
|
61
|
+
- lib/hitimes/value_metric.rb
|
49
62
|
- lib/hitimes/version.rb
|
50
63
|
- lib/hitimes.rb
|
51
64
|
- ext/hitimes_ext.c
|
@@ -68,18 +81,24 @@ files:
|
|
68
81
|
- ext/extconf.rb
|
69
82
|
- ext/rbconfig-mingw.rb
|
70
83
|
- ext/rbconfig.rb
|
84
|
+
- lib/hitimes/metric.rb
|
71
85
|
- lib/hitimes/mutexed_stats.rb
|
72
86
|
- lib/hitimes/paths.rb
|
73
87
|
- lib/hitimes/stats.rb
|
74
|
-
- lib/hitimes/
|
88
|
+
- lib/hitimes/timed_metric.rb
|
89
|
+
- lib/hitimes/timed_value_metric.rb
|
90
|
+
- lib/hitimes/value_metric.rb
|
75
91
|
- lib/hitimes/version.rb
|
76
92
|
- lib/hitimes.rb
|
77
93
|
- spec/interval_spec.rb
|
94
|
+
- spec/metric_spec.rb
|
78
95
|
- spec/mutex_stats_spec.rb
|
79
96
|
- spec/paths_spec.rb
|
80
97
|
- spec/spec_helper.rb
|
81
98
|
- spec/stats_spec.rb
|
82
|
-
- spec/
|
99
|
+
- spec/timed_metric_spec.rb
|
100
|
+
- spec/timed_value_metric_spec.rb
|
101
|
+
- spec/value_metric_spec.rb
|
83
102
|
- spec/version_spec.rb
|
84
103
|
- README
|
85
104
|
- HISTORY
|
data/lib/hitimes/timer.rb
DELETED
@@ -1,223 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2008 Jeremy Hinegardner
|
3
|
-
# All rights reserved. See LICENSE and/or COPYING for details.
|
4
|
-
#++
|
5
|
-
|
6
|
-
require 'hitimes'
|
7
|
-
require 'hitimes_ext'
|
8
|
-
|
9
|
-
module Hitimes
|
10
|
-
#
|
11
|
-
# A Timer combines together an Interval and a Stats object to provide
|
12
|
-
# aggregate information about timings.
|
13
|
-
#
|
14
|
-
# A Timer has many of the same methods as an Interval and would be used in
|
15
|
-
# preference to an Interval in those situations where you want to track
|
16
|
-
# statistics about the item you are monitoring.
|
17
|
-
#
|
18
|
-
class Timer
|
19
|
-
|
20
|
-
# holds all the statistics
|
21
|
-
attr_reader :stats
|
22
|
-
|
23
|
-
class << self
|
24
|
-
|
25
|
-
#
|
26
|
-
# :call-seq:
|
27
|
-
# Timer.now -> Timer
|
28
|
-
#
|
29
|
-
# Return a newly allocated Timer that has already been started
|
30
|
-
#
|
31
|
-
def now
|
32
|
-
t = Timer.new
|
33
|
-
t.start
|
34
|
-
return t
|
35
|
-
end
|
36
|
-
|
37
|
-
#
|
38
|
-
# :call-seq:
|
39
|
-
# Timer.measure { ... } -> Float
|
40
|
-
#
|
41
|
-
# Return the number of seconds that a block of code took to
|
42
|
-
# execute.
|
43
|
-
#
|
44
|
-
def measure( &block )
|
45
|
-
Interval.measure { yield }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
#
|
50
|
-
# :call-seq:
|
51
|
-
# Timer.new -> Timer
|
52
|
-
#
|
53
|
-
def initialize
|
54
|
-
@stats = Stats.new
|
55
|
-
@current_interval = nil
|
56
|
-
end
|
57
|
-
|
58
|
-
#
|
59
|
-
# :call-seq:
|
60
|
-
# timer.current_interval -> Interval
|
61
|
-
#
|
62
|
-
# Return the current interval, if one doesn't exist create one.
|
63
|
-
#
|
64
|
-
def current_interval
|
65
|
-
@current_interval ||= Interval.new
|
66
|
-
end
|
67
|
-
|
68
|
-
#
|
69
|
-
# :call-seq:
|
70
|
-
# timer.running? -> true or false
|
71
|
-
#
|
72
|
-
# return whether or not the timer is currently running.
|
73
|
-
#
|
74
|
-
def running?
|
75
|
-
current_interval.running?
|
76
|
-
end
|
77
|
-
|
78
|
-
#
|
79
|
-
# :call-seq:
|
80
|
-
# timer.start -> nil
|
81
|
-
#
|
82
|
-
# Start the current timer, if the current timer is already started, then
|
83
|
-
# this is a noop.
|
84
|
-
#
|
85
|
-
def start
|
86
|
-
current_interval.start unless running?
|
87
|
-
nil
|
88
|
-
end
|
89
|
-
|
90
|
-
#
|
91
|
-
# :call-seq:
|
92
|
-
# timer.stop -> Float or nil
|
93
|
-
#
|
94
|
-
# Stop the current timer. This updates the stats and removes the current
|
95
|
-
# interval. If the timer is not running then this is a noop. If the
|
96
|
-
# timer was stopped then the duration of the last Interval is returned. If
|
97
|
-
# the timer was already stopped then false is returned.
|
98
|
-
#
|
99
|
-
def stop
|
100
|
-
if running? then
|
101
|
-
d = current_interval.stop
|
102
|
-
@current_interval = nil
|
103
|
-
stats.update( d )
|
104
|
-
return d
|
105
|
-
end
|
106
|
-
return false
|
107
|
-
end
|
108
|
-
|
109
|
-
#
|
110
|
-
# :call-seq:
|
111
|
-
# timer.measure { ... } -> Float
|
112
|
-
#
|
113
|
-
# Measure the execution of a block and add those stats to the running stats.
|
114
|
-
#
|
115
|
-
def measure( &block )
|
116
|
-
t = 0.0
|
117
|
-
begin
|
118
|
-
start
|
119
|
-
yield
|
120
|
-
ensure
|
121
|
-
t = stop
|
122
|
-
end
|
123
|
-
return t
|
124
|
-
end
|
125
|
-
|
126
|
-
#
|
127
|
-
# :call-seq:
|
128
|
-
# timer.split -> Flaot
|
129
|
-
#
|
130
|
-
# Split the current timer. Essentially, mark a split time. This means
|
131
|
-
# stop the current interval and create a new interval, but make sure
|
132
|
-
# that the new interval lines up exactly, timewise, behind the previous
|
133
|
-
# interval.
|
134
|
-
#
|
135
|
-
# If the timer is running, then split returns the duration of the previous
|
136
|
-
# interval, i.e. the split-time. If the timer is not running, nothing
|
137
|
-
# happens and false is returned.
|
138
|
-
#
|
139
|
-
def split
|
140
|
-
if running? then
|
141
|
-
next_interval = current_interval.split
|
142
|
-
d = current_interval.duration
|
143
|
-
stats.update( d )
|
144
|
-
@current_interval = next_interval
|
145
|
-
return d
|
146
|
-
end
|
147
|
-
return false
|
148
|
-
end
|
149
|
-
|
150
|
-
#
|
151
|
-
# :call-seq:
|
152
|
-
# timer.sum -> Float
|
153
|
-
# timer.duration -> Float
|
154
|
-
#
|
155
|
-
# The total time the timer has been measuring.
|
156
|
-
#
|
157
|
-
def sum
|
158
|
-
stats.sum
|
159
|
-
end
|
160
|
-
alias duration sum
|
161
|
-
|
162
|
-
#
|
163
|
-
# :call-seq:
|
164
|
-
# timer.mean -> Float
|
165
|
-
#
|
166
|
-
# The mean value of all the the stopped intervals. The current interval, if
|
167
|
-
# it is still running, is not included.
|
168
|
-
#
|
169
|
-
def mean
|
170
|
-
stats.mean
|
171
|
-
end
|
172
|
-
|
173
|
-
#
|
174
|
-
# :call-seq:
|
175
|
-
# timer.rate -> Float
|
176
|
-
#
|
177
|
-
# Return the rate of the states, which is the count / duration
|
178
|
-
#
|
179
|
-
def rate
|
180
|
-
stats.rate
|
181
|
-
end
|
182
|
-
|
183
|
-
#
|
184
|
-
# :call-seq:
|
185
|
-
# timer.stddev -> Float
|
186
|
-
#
|
187
|
-
# The standard deviation of all the intervals
|
188
|
-
#
|
189
|
-
def stddev
|
190
|
-
stats.stddev
|
191
|
-
end
|
192
|
-
|
193
|
-
#
|
194
|
-
# :call-seq:
|
195
|
-
# timer.count -> Integer
|
196
|
-
#
|
197
|
-
# The count of intervals in this timer
|
198
|
-
#
|
199
|
-
def count
|
200
|
-
stats.count
|
201
|
-
end
|
202
|
-
|
203
|
-
#
|
204
|
-
# :call-seq:
|
205
|
-
# timer.max -> Float
|
206
|
-
#
|
207
|
-
# The maximum duration of all the intervals this Timer has seen
|
208
|
-
#
|
209
|
-
def max
|
210
|
-
stats.max
|
211
|
-
end
|
212
|
-
|
213
|
-
#
|
214
|
-
# :call-seq:
|
215
|
-
# timer.min -> Float
|
216
|
-
#
|
217
|
-
# The minimum duration of all the intervals this Timer has seen
|
218
|
-
#
|
219
|
-
def min
|
220
|
-
stats.min
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|
data/spec/timer_spec.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
|
2
|
-
|
3
|
-
require 'hitimes/timer'
|
4
|
-
|
5
|
-
describe Hitimes::Timer do
|
6
|
-
|
7
|
-
it "knows if it is running or not" do
|
8
|
-
t = Hitimes::Timer.new
|
9
|
-
t.should_not be_running
|
10
|
-
t.start
|
11
|
-
t.should be_running
|
12
|
-
t.stop
|
13
|
-
t.should_not be_running
|
14
|
-
end
|
15
|
-
|
16
|
-
it "#split returns the last duration and the timer is still running" do
|
17
|
-
t = Hitimes::Timer.now
|
18
|
-
d = t.split
|
19
|
-
t.should be_running
|
20
|
-
d.should > 0
|
21
|
-
t.count.should == 1
|
22
|
-
t.duration.should == d
|
23
|
-
end
|
24
|
-
|
25
|
-
it "#stop returns false if called more than once in a row" do
|
26
|
-
t = Hitimes::Timer.new
|
27
|
-
t.start
|
28
|
-
t.stop.should > 0
|
29
|
-
t.stop.should == false
|
30
|
-
end
|
31
|
-
|
32
|
-
it "does not count a currently running interval as an interval in calculations" do
|
33
|
-
t = Hitimes::Timer.new
|
34
|
-
t.start
|
35
|
-
t.count.should == 0
|
36
|
-
t.split
|
37
|
-
t.count.should == 1
|
38
|
-
end
|
39
|
-
|
40
|
-
it "#split called on a stopped timer does nothing" do
|
41
|
-
t = Hitimes::Timer.new
|
42
|
-
t.start
|
43
|
-
t.stop
|
44
|
-
t.split.should == false
|
45
|
-
end
|
46
|
-
|
47
|
-
it "calculates the mean of the durations" do
|
48
|
-
t = Hitimes::Timer.new
|
49
|
-
2.times { t.start ; sleep 0.05 ; t.stop }
|
50
|
-
t.mean.should > 0.04
|
51
|
-
end
|
52
|
-
|
53
|
-
it "calculates the rate of the counts " do
|
54
|
-
t = Hitimes::Timer.new
|
55
|
-
5.times { t.start ; sleep 0.05 ; t.stop }
|
56
|
-
t.rate.should > 19.0
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
it "calculates the stddev of the durations" do
|
61
|
-
t = Hitimes::Timer.new
|
62
|
-
2.times { t.start ; sleep 0.05 ; t.stop }
|
63
|
-
t.stddev.should > 0.0
|
64
|
-
end
|
65
|
-
|
66
|
-
it "returns 0.0 for stddev if there is no data" do
|
67
|
-
t = Hitimes::Timer.new
|
68
|
-
t.stddev.should == 0.0
|
69
|
-
end
|
70
|
-
|
71
|
-
it "retuns 0.0 for mean if there is no data" do
|
72
|
-
Hitimes::Timer.new.mean.should == 0.0
|
73
|
-
end
|
74
|
-
|
75
|
-
it "keeps track of the min value" do
|
76
|
-
t = Hitimes::Timer.new
|
77
|
-
2.times { t.start ; sleep 0.05 ; t.stop }
|
78
|
-
t.min.should > 0
|
79
|
-
end
|
80
|
-
|
81
|
-
it "keeps track of the max value" do
|
82
|
-
t = Hitimes::Timer.new
|
83
|
-
2.times { t.start ; sleep 0.05 ; t.stop }
|
84
|
-
t.max.should > 0
|
85
|
-
end
|
86
|
-
|
87
|
-
it "can create an already running timer" do
|
88
|
-
t = Hitimes::Timer.now
|
89
|
-
t.should be_running
|
90
|
-
end
|
91
|
-
|
92
|
-
it "can measure a block of code's execution time" do
|
93
|
-
dur = Hitimes::Timer.measure { sleep 0.05 }
|
94
|
-
dur.should > 0.025
|
95
|
-
end
|
96
|
-
|
97
|
-
it "can measuer a block of code from an instance" do
|
98
|
-
t = Hitimes::Timer.new
|
99
|
-
3.times { t.measure { sleep 0.05 } }
|
100
|
-
t.duration.should > 0.14
|
101
|
-
t.count.should == 3
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|