hitimes 1.1.1-java → 1.2.0-java
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/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/{java → hitimes/java}/src/hitimes/Hitimes.java +1 -1
- data/ext/{java → hitimes/java}/src/hitimes/HitimesInterval.java +8 -1
- data/ext/{java → hitimes/java}/src/hitimes/HitimesService.java +0 -0
- data/ext/{java → hitimes/java}/src/hitimes/HitimesStats.java +0 -0
- data/lib/hitimes.rb +15 -5
- data/lib/hitimes/hitimes.jar +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 +185 -182
- data/ext/hitimes/hitimes_instant_osx.c +0 -16
- data/gemspec.rb +0 -64
- 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/spec/timed_metric_spec.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require 'hitimes/timed_metric'
|
1
|
+
require 'spec_helper'
|
4
2
|
|
5
3
|
describe Hitimes::TimedMetric do
|
6
4
|
before( :each ) do
|
@@ -19,76 +17,76 @@ describe Hitimes::TimedMetric do
|
|
19
17
|
@tm.start
|
20
18
|
d = @tm.split
|
21
19
|
@tm.should be_running
|
22
|
-
d.should > 0
|
23
|
-
@tm.count.should == 1
|
24
|
-
@tm.duration.should == d
|
20
|
+
d.should be > 0
|
21
|
+
@tm.count.should be == 1
|
22
|
+
@tm.duration.should be == d
|
25
23
|
end
|
26
24
|
|
27
25
|
it "#stop returns false if called more than once in a row" do
|
28
26
|
@tm.start
|
29
|
-
@tm.stop.should > 0
|
30
|
-
@tm.stop.should == false
|
27
|
+
@tm.stop.should be > 0
|
28
|
+
@tm.stop.should be == false
|
31
29
|
end
|
32
30
|
|
33
31
|
it "does not count a currently running interval as an interval in calculations" do
|
34
32
|
@tm.start
|
35
|
-
@tm.count.should == 0
|
33
|
+
@tm.count.should be == 0
|
36
34
|
@tm.split
|
37
|
-
@tm.count.should == 1
|
35
|
+
@tm.count.should be == 1
|
38
36
|
end
|
39
37
|
|
40
38
|
it "#split called on a stopped timer does nothing" do
|
41
39
|
@tm.start
|
42
40
|
@tm.stop
|
43
|
-
@tm.split.should == false
|
41
|
+
@tm.split.should be == false
|
44
42
|
end
|
45
43
|
|
46
44
|
it "calculates the mean of the durations" do
|
47
45
|
2.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
48
|
-
@tm.mean.should
|
46
|
+
@tm.mean.should be_within(0.01).of(0.05)
|
49
47
|
end
|
50
48
|
|
51
49
|
it "calculates the rate of the counts " do
|
52
50
|
5.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
53
|
-
@tm.rate.should
|
51
|
+
@tm.rate.should be_within(1.0).of(20.00)
|
54
52
|
end
|
55
53
|
|
56
54
|
|
57
55
|
it "calculates the stddev of the durations" do
|
58
|
-
3.times { |x| @tm.start ; sleep
|
59
|
-
@tm.stddev.should
|
56
|
+
3.times { |x| @tm.start ; sleep(0.05 * x) ; @tm.stop }
|
57
|
+
@tm.stddev.should be_within(0.002).of( 0.05)
|
60
58
|
end
|
61
59
|
|
62
60
|
it "returns 0.0 for stddev if there is no data" do
|
63
|
-
@tm.stddev.should == 0.0
|
61
|
+
@tm.stddev.should be == 0.0
|
64
62
|
end
|
65
63
|
|
66
64
|
it "keeps track of the min value" do
|
67
65
|
2.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
68
|
-
@tm.min.should
|
66
|
+
@tm.min.should be_within( 0.002 ).of(0.05)
|
69
67
|
end
|
70
68
|
|
71
69
|
it "keeps track of the max value" do
|
72
70
|
2.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
73
|
-
@tm.max.should
|
71
|
+
@tm.max.should be_within( 0.002 ).of(0.05)
|
74
72
|
end
|
75
73
|
|
76
74
|
it "keeps track of the sum value" do
|
77
75
|
2.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
78
|
-
@tm.sum.should
|
76
|
+
@tm.sum.should be_within( 0.005 ).of(0.10)
|
79
77
|
end
|
80
|
-
|
78
|
+
|
81
79
|
it "keeps track of the sum of squars value" do
|
82
80
|
3.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
83
|
-
@tm.sumsq.should
|
81
|
+
@tm.sumsq.should be_within(0.001).of(0.0075)
|
84
82
|
end
|
85
83
|
|
86
84
|
it "keeps track of the minimum start time of all the intervals" do
|
87
85
|
f1 = Time.now.gmtime.to_f * 1_000_000
|
88
86
|
5.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
89
87
|
f2 = Time.now.gmtime.to_f * 1_000_000
|
90
|
-
@tm.sampling_start_time.should >= f1
|
91
|
-
@tm.sampling_start_time.should < f2
|
88
|
+
@tm.sampling_start_time.should be >= f1
|
89
|
+
@tm.sampling_start_time.should be < f2
|
92
90
|
# distance from now to start time should be greater than the distance from
|
93
91
|
# the start to the min start_time
|
94
92
|
(f2 - @tm.sampling_start_time).should > ( @tm.sampling_start_time - f1 )
|
@@ -96,10 +94,12 @@ describe Hitimes::TimedMetric do
|
|
96
94
|
|
97
95
|
it "keeps track of the last stop time of all the intervals" do
|
98
96
|
f1 = Time.now.gmtime.to_f * 1_000_000
|
97
|
+
sleep 0.01
|
99
98
|
5.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
99
|
+
sleep 0.01
|
100
100
|
f2 = Time.now.gmtime.to_f * 1_000_000
|
101
|
-
@tm.sampling_stop_time.should > f1
|
102
|
-
@tm.sampling_stop_time.should <= f2
|
101
|
+
@tm.sampling_stop_time.should be > f1
|
102
|
+
@tm.sampling_stop_time.should be <= f2
|
103
103
|
# distance from now to max stop time time should be less than the distance
|
104
104
|
# from the start to the max stop time
|
105
105
|
(f2 - @tm.sampling_stop_time).should < ( @tm.sampling_stop_time - f1 )
|
@@ -113,34 +113,34 @@ describe Hitimes::TimedMetric do
|
|
113
113
|
it "can measure a block of code from an instance" do
|
114
114
|
t = Hitimes::TimedMetric.new( 'measure a block' )
|
115
115
|
3.times { t.measure { sleep 0.05 } }
|
116
|
-
t.duration.should
|
117
|
-
t.count.should == 3
|
116
|
+
t.duration.should be_within(0.01).of(0.15)
|
117
|
+
t.count.should be == 3
|
118
118
|
end
|
119
119
|
|
120
120
|
it "returns the value of the block when measuring" do
|
121
121
|
t = Hitimes::TimedMetric.new( 'measure a block' )
|
122
122
|
x = t.measure { sleep 0.05; 42 }
|
123
|
-
t.duration.should
|
124
|
-
x.should == 42
|
123
|
+
t.duration.should be_within(0.002).of(0.05)
|
124
|
+
x.should be == 42
|
125
125
|
end
|
126
126
|
|
127
127
|
describe "#to_hash" do
|
128
128
|
|
129
129
|
it "has name value" do
|
130
130
|
h = @tm.to_hash
|
131
|
-
h['name'].should == "test-timed-metric"
|
131
|
+
h['name'].should be == "test-timed-metric"
|
132
132
|
end
|
133
133
|
|
134
134
|
it "has an empty hash for additional_data" do
|
135
135
|
h = @tm.to_hash
|
136
|
-
h['additional_data'].should == Hash.new
|
137
|
-
h['additional_data'].size.should == 0
|
136
|
+
h['additional_data'].should be == Hash.new
|
137
|
+
h['additional_data'].size.should be == 0
|
138
138
|
end
|
139
139
|
|
140
140
|
it "has the right sum" do
|
141
141
|
10.times { |x| @tm.measure { sleep 0.01*x } }
|
142
142
|
h = @tm.to_hash
|
143
|
-
h['sum'].should
|
143
|
+
h['sum'].should be_within( 0.01).of(0.45)
|
144
144
|
end
|
145
145
|
|
146
146
|
fields = ::Hitimes::Stats::STATS.dup + %w[ name additional_data sampling_start_time sampling_stop_time ]
|
@@ -1,6 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require 'hitimes/timed_value_metric'
|
1
|
+
require 'spec_helper'
|
4
2
|
|
5
3
|
describe Hitimes::TimedValueMetric do
|
6
4
|
before( :each ) do
|
@@ -19,97 +17,98 @@ describe Hitimes::TimedValueMetric do
|
|
19
17
|
@tm.start
|
20
18
|
d = @tm.split( 1 )
|
21
19
|
@tm.should be_running
|
22
|
-
d.should > 0
|
23
|
-
@tm.value_stats.count.should == 1
|
24
|
-
@tm.timed_stats.count.should == 1
|
25
|
-
@tm.duration.should == d
|
20
|
+
d.should be > 0
|
21
|
+
@tm.value_stats.count.should be == 1
|
22
|
+
@tm.timed_stats.count.should be == 1
|
23
|
+
@tm.duration.should be == d
|
26
24
|
end
|
27
25
|
|
28
26
|
it "#stop returns false if called more than once in a row" do
|
29
27
|
@tm.start
|
30
|
-
@tm.stop( 1 ).should > 0
|
31
|
-
@tm.stop( 1 ).should == false
|
28
|
+
@tm.stop( 1 ).should be > 0
|
29
|
+
@tm.stop( 1 ).should be == false
|
32
30
|
end
|
33
31
|
|
34
32
|
it "does not count a currently running interval as an interval in calculations" do
|
35
33
|
@tm.start
|
36
|
-
@tm.value_stats.count.should == 0
|
37
|
-
@tm.timed_stats.count.should == 0
|
34
|
+
@tm.value_stats.count.should be == 0
|
35
|
+
@tm.timed_stats.count.should be == 0
|
38
36
|
@tm.split( 1 )
|
39
|
-
@tm.value_stats.count.should == 1
|
40
|
-
@tm.timed_stats.count.should == 1
|
37
|
+
@tm.value_stats.count.should be == 1
|
38
|
+
@tm.timed_stats.count.should be == 1
|
41
39
|
end
|
42
40
|
|
43
41
|
it "#split called on a stopped timer does nothing" do
|
44
42
|
@tm.start
|
45
43
|
@tm.stop( 1 )
|
46
|
-
@tm.split( 1 ).should == false
|
44
|
+
@tm.split( 1 ).should be == false
|
47
45
|
end
|
48
46
|
|
49
47
|
it "calculates the mean of the durations" do
|
50
48
|
3.times { |x| @tm.start ; sleep 0.05 ; @tm.stop(x) }
|
51
|
-
@tm.timed_stats.mean.should
|
52
|
-
@tm.value_stats.mean.should == 1.00
|
49
|
+
@tm.timed_stats.mean.should be_within(0.01).of(0.05)
|
50
|
+
@tm.value_stats.mean.should be == 1.00
|
53
51
|
end
|
54
52
|
|
55
53
|
it "calculates the rate of the counts " do
|
56
54
|
5.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
57
|
-
@tm.rate.should
|
55
|
+
@tm.rate.should be_within(1.0).of(40.0)
|
58
56
|
end
|
59
57
|
|
60
58
|
|
61
59
|
it "calculates the stddev of the durations" do
|
62
|
-
3.times { |x| @tm.start ; sleep
|
63
|
-
@tm.timed_stats.stddev.should
|
64
|
-
@tm.value_stats.stddev.should == 1.0
|
60
|
+
3.times { |x| @tm.start ; sleep(0.05 * x) ; @tm.stop(x) }
|
61
|
+
@tm.timed_stats.stddev.should be_within(0.001).of(0.05)
|
62
|
+
@tm.value_stats.stddev.should be == 1.0
|
65
63
|
end
|
66
64
|
|
67
65
|
it "returns 0.0 for stddev if there is no data" do
|
68
|
-
@tm.timed_stats.stddev.should == 0.0
|
69
|
-
@tm.value_stats.stddev.should == 0.0
|
66
|
+
@tm.timed_stats.stddev.should be == 0.0
|
67
|
+
@tm.value_stats.stddev.should be == 0.0
|
70
68
|
end
|
71
69
|
|
72
70
|
it "keeps track of the min value" do
|
73
71
|
3.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
74
|
-
@tm.timed_stats.min.should
|
75
|
-
@tm.value_stats.min.should == 0
|
72
|
+
@tm.timed_stats.min.should be_within( 0.003 ).of(0.05)
|
73
|
+
@tm.value_stats.min.should be == 0
|
76
74
|
end
|
77
75
|
|
78
76
|
it "keeps track of the max value" do
|
79
77
|
3.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
80
|
-
@tm.timed_stats.max.should
|
81
|
-
@tm.value_stats.max.should == 2
|
78
|
+
@tm.timed_stats.max.should be_within(0.003).of( 0.05 )
|
79
|
+
@tm.value_stats.max.should be == 2
|
82
80
|
end
|
83
81
|
|
84
82
|
it "keeps track of the sum value" do
|
85
83
|
3.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
86
|
-
@tm.timed_stats.sum.should
|
87
|
-
@tm.value_stats.sum.should == 3
|
84
|
+
@tm.timed_stats.sum.should be_within(0.01).of(0.15)
|
85
|
+
@tm.value_stats.sum.should be == 3
|
88
86
|
end
|
89
87
|
|
90
88
|
it "keeps track of the sum of squares value" do
|
91
89
|
3.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
92
|
-
@tm.timed_stats.sumsq.should
|
93
|
-
@tm.value_stats.sumsq.should == 5
|
90
|
+
@tm.timed_stats.sumsq.should be_within(0.0005).of(0.0075)
|
91
|
+
@tm.value_stats.sumsq.should be == 5
|
94
92
|
end
|
95
93
|
|
96
94
|
it "keeps track of the minimum start time of all the intervals" do
|
97
95
|
f1 = Time.now.gmtime.to_f * 1000000
|
98
96
|
5.times { @tm.start ; sleep 0.05 ; @tm.stop( 1 ) }
|
99
97
|
f2 = Time.now.gmtime.to_f * 1000000
|
100
|
-
@tm.sampling_start_time.should >= f1
|
101
|
-
@tm.sampling_start_time.should < f2
|
98
|
+
@tm.sampling_start_time.should be >= f1
|
99
|
+
@tm.sampling_start_time.should be < f2
|
102
100
|
# distance from now to start time should be greater than the distance from
|
103
101
|
# the start to the min start_time
|
104
102
|
(f2 - @tm.sampling_start_time).should > ( @tm.sampling_start_time - f1 )
|
105
103
|
end
|
106
104
|
|
107
105
|
it "keeps track of the last stop time of all the intervals" do
|
108
|
-
f1 = Time.now.gmtime.to_f *
|
106
|
+
f1 = Time.now.gmtime.to_f * 1_000_000
|
109
107
|
5.times { @tm.start ; sleep 0.05 ; @tm.stop( 1 ) }
|
110
|
-
|
111
|
-
|
112
|
-
@tm.sampling_stop_time.should
|
108
|
+
sleep 0.05
|
109
|
+
f2 = Time.now.gmtime.to_f * 1_000_000
|
110
|
+
@tm.sampling_stop_time.should be > f1
|
111
|
+
@tm.sampling_stop_time.should be <= f2
|
113
112
|
# distance from now to max stop time time should be less than the distance
|
114
113
|
# from the start to the max stop time
|
115
114
|
(f2 - @tm.sampling_stop_time).should < ( @tm.sampling_stop_time - f1 )
|
@@ -123,41 +122,41 @@ describe Hitimes::TimedValueMetric do
|
|
123
122
|
it "can measure a block of code from an instance" do
|
124
123
|
t = Hitimes::TimedValueMetric.new( 'measure a block' )
|
125
124
|
3.times { t.measure( 1 ) { sleep 0.05 } }
|
126
|
-
t.duration.should
|
127
|
-
t.timed_stats.count.should == 3
|
128
|
-
t.value_stats.count.should == 3
|
125
|
+
t.duration.should be_within(0.004).of(0.15)
|
126
|
+
t.timed_stats.count.should be == 3
|
127
|
+
t.value_stats.count.should be == 3
|
129
128
|
end
|
130
129
|
|
131
130
|
it "returns the value of the block when measuring" do
|
132
131
|
t = Hitimes::TimedValueMetric.new( 'measure a block' )
|
133
132
|
x = t.measure( 42 ) { sleep 0.05; 42 }
|
134
|
-
t.duration.should
|
135
|
-
x.should == 42
|
133
|
+
t.duration.should be_within(0.002).of(0.05)
|
134
|
+
x.should be == 42
|
136
135
|
end
|
137
136
|
|
138
137
|
describe "#to_hash" do
|
139
138
|
|
140
139
|
it "has name value" do
|
141
140
|
h = @tm.to_hash
|
142
|
-
h['name'].should == "test-timed-value-metric"
|
141
|
+
h['name'].should be == "test-timed-value-metric"
|
143
142
|
end
|
144
143
|
|
145
144
|
it "has an empty has for additional_data" do
|
146
145
|
h = @tm.to_hash
|
147
|
-
h['additional_data'].should == Hash.new
|
148
|
-
h['additional_data'].size.should == 0
|
146
|
+
h['additional_data'].should be == Hash.new
|
147
|
+
h['additional_data'].size.should be == 0
|
149
148
|
end
|
150
149
|
|
151
150
|
it "has a rate" do
|
152
151
|
5.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
153
152
|
h = @tm.to_hash
|
154
|
-
h['rate'].should
|
153
|
+
h['rate'].should be_within(1.0 ).of(40.0)
|
155
154
|
end
|
156
155
|
|
157
156
|
it "has a unit_count" do
|
158
157
|
5.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
159
158
|
h = @tm.to_hash
|
160
|
-
h['unit_count'].should == 10
|
159
|
+
h['unit_count'].should be == 10
|
161
160
|
end
|
162
161
|
|
163
162
|
fields = %w[ name additional_data sampling_start_time sampling_stop_time value_stats timed_stats rate unit_count ]
|
data/spec/value_metric_spec.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require 'hitimes/value_metric'
|
1
|
+
require 'spec_helper'
|
4
2
|
|
5
3
|
describe Hitimes::ValueMetric do
|
6
4
|
before( :each ) do
|
@@ -9,21 +7,21 @@ describe Hitimes::ValueMetric do
|
|
9
7
|
end
|
10
8
|
|
11
9
|
it 'has a name' do
|
12
|
-
@metric.name.should == "testing"
|
10
|
+
@metric.name.should be == "testing"
|
13
11
|
end
|
14
12
|
|
15
13
|
it "has associated data from initialization" do
|
16
14
|
m = Hitimes::ValueMetric.new( "more-data", 'foo' => 'bar', 'this' => 'that' )
|
17
|
-
m.additional_data['foo'].should == 'bar'
|
18
|
-
m.additional_data['this'].should == 'that'
|
15
|
+
m.additional_data['foo'].should be == 'bar'
|
16
|
+
m.additional_data['this'].should be == 'that'
|
19
17
|
|
20
18
|
m = Hitimes::ValueMetric.new( "more-data", { 'foo' => 'bar', 'this' => 'that' } )
|
21
|
-
m.additional_data['foo'].should == 'bar'
|
22
|
-
m.additional_data['this'].should == 'that'
|
19
|
+
m.additional_data['foo'].should be == 'bar'
|
20
|
+
m.additional_data['this'].should be == 'that'
|
23
21
|
end
|
24
22
|
|
25
23
|
it "calculates the mean of the measurements" do
|
26
|
-
@metric.mean.should == 4.5
|
24
|
+
@metric.mean.should be == 4.5
|
27
25
|
end
|
28
26
|
|
29
27
|
it "calculates the stddev of the measurements" do
|
@@ -32,27 +30,27 @@ describe Hitimes::ValueMetric do
|
|
32
30
|
|
33
31
|
it "returns 0.0 for stddev if there is no data" do
|
34
32
|
m = Hitimes::ValueMetric.new('0-data')
|
35
|
-
m.stddev.should == 0.0
|
33
|
+
m.stddev.should be == 0.0
|
36
34
|
end
|
37
35
|
|
38
36
|
it "keeps track of the sum of data" do
|
39
|
-
@metric.sum.should == 45.0
|
37
|
+
@metric.sum.should be == 45.0
|
40
38
|
end
|
41
39
|
|
42
40
|
it "keeps track of the sum of squars of data" do
|
43
|
-
@metric.sumsq.should == 285.0
|
41
|
+
@metric.sumsq.should be == 285.0
|
44
42
|
end
|
45
43
|
|
46
44
|
it "retuns 0.0 for mean if there is no data" do
|
47
|
-
Hitimes::ValueMetric.new('0-data').mean.should == 0.0
|
45
|
+
Hitimes::ValueMetric.new('0-data').mean.should be == 0.0
|
48
46
|
end
|
49
47
|
|
50
48
|
it "keeps track of the min value" do
|
51
|
-
@metric.min.should == 0
|
49
|
+
@metric.min.should be == 0
|
52
50
|
end
|
53
51
|
|
54
52
|
it "keeps track of the max value" do
|
55
|
-
@metric.max.should == 9
|
53
|
+
@metric.max.should be == 9
|
56
54
|
end
|
57
55
|
|
58
56
|
it "keeps track of the first start time of all the measurements" do
|
@@ -60,8 +58,8 @@ describe Hitimes::ValueMetric do
|
|
60
58
|
f1 = Time.now.gmtime.to_f * 1_000_000
|
61
59
|
10.times{ |x| m.measure( x ); sleep 0.1 }
|
62
60
|
f2 = Time.now.gmtime.to_f * 1_000_000
|
63
|
-
m.sampling_start_time.should >= f1
|
64
|
-
m.sampling_start_time.should < f2
|
61
|
+
m.sampling_start_time.should be >= f1
|
62
|
+
m.sampling_start_time.should be < f2
|
65
63
|
# distance from now to start time should be greater than the distance from
|
66
64
|
# the start to the min start_time
|
67
65
|
(f2 - m.sampling_start_time).should > ( m.sampling_start_time - f1 )
|
@@ -72,8 +70,8 @@ describe Hitimes::ValueMetric do
|
|
72
70
|
f1 = Time.now.gmtime.to_f * 1_000_000
|
73
71
|
10.times {|x| m.measure( x ); sleep 0.1 }
|
74
72
|
f2 = Time.now.gmtime.to_f * 1_000_000
|
75
|
-
m.sampling_stop_time.should > f1
|
76
|
-
m.sampling_stop_time.should <= f2
|
73
|
+
m.sampling_stop_time.should be > f1
|
74
|
+
m.sampling_stop_time.should be <= f2
|
77
75
|
# distance from now to max stop time time should be less than the distance
|
78
76
|
# from the start to the max stop time
|
79
77
|
(f2 - m.sampling_stop_time).should < ( m.sampling_stop_time - f1 )
|
@@ -83,18 +81,18 @@ describe Hitimes::ValueMetric do
|
|
83
81
|
|
84
82
|
it "has name value" do
|
85
83
|
h = @metric.to_hash
|
86
|
-
h['name'].should == "testing"
|
84
|
+
h['name'].should be == "testing"
|
87
85
|
end
|
88
86
|
|
89
87
|
it "has an empty has for additional_data" do
|
90
88
|
h = @metric.to_hash
|
91
|
-
h['additional_data'].should == Hash.new
|
92
|
-
h['additional_data'].size.should == 0
|
89
|
+
h['additional_data'].should be == Hash.new
|
90
|
+
h['additional_data'].size.should be == 0
|
93
91
|
end
|
94
92
|
|
95
93
|
it "has the right sum" do
|
96
94
|
h = @metric.to_hash
|
97
|
-
h['sum'].should == 45
|
95
|
+
h['sum'].should be == 45
|
98
96
|
end
|
99
97
|
|
100
98
|
fields = ::Hitimes::Stats::STATS.dup + %w[ name additional_data sampling_start_time sampling_stop_time ]
|