hitimes 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +11 -0
- data/HISTORY.md +5 -0
- data/Manifest.txt +1 -0
- data/Rakefile +5 -4
- data/ext/hitimes/c/extconf.rb +7 -0
- data/lib/hitimes/version.rb +1 -1
- data/spec/hitimes_spec.rb +2 -2
- data/spec/interval_spec.rb +33 -33
- data/spec/metric_spec.rb +7 -7
- data/spec/mutex_stats_spec.rb +3 -3
- data/spec/paths_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -1
- data/spec/stats_spec.rb +27 -27
- data/spec/timed_metric_spec.rb +37 -37
- data/spec/timed_value_metric_spec.rb +49 -49
- data/spec/value_metric_spec.rb +25 -25
- data/spec/version_spec.rb +1 -1
- data/tasks/default.rake +13 -8
- data/tasks/this.rb +8 -3
- metadata +29 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 656918024e2e0b7c84864f63ec2fb51a0f0af28a
|
4
|
+
data.tar.gz: ac489662afdf40c26d0e6dec7ceb499c72757ed3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b826ec301a437778827083ec4da19a1f1cfaa404bf215d67a95059799e84348bd87991d65cbe593f47b9d3b12be47ed7082fedd498e54c97fc7f38eaa8eb65cf
|
7
|
+
data.tar.gz: 5f7b5af970ff2a0eb6748f19b4ecefd1fecea6042ccbeae8cc4678e2f099920ca8067bf1841636c2218060dca8bc32eeffe34001b84b0b9361a6bf374eb8345a
|
data/.travis.yml
ADDED
data/HISTORY.md
CHANGED
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
@@ -7,13 +7,14 @@ This.email = "jeremy@copiousfreetime.org"
|
|
7
7
|
This.homepage = "http://github.com/copiousfreetime/#{ This.name }"
|
8
8
|
|
9
9
|
This.ruby_gemspec do |spec|
|
10
|
-
spec.add_development_dependency( 'rake' , '~> 10.0
|
11
|
-
spec.add_development_dependency( '
|
12
|
-
spec.add_development_dependency( 'rdoc' , '~> 4.
|
10
|
+
spec.add_development_dependency( 'rake' , '~> 10.0')
|
11
|
+
spec.add_development_dependency( 'minitest' , '~> 5.3' )
|
12
|
+
spec.add_development_dependency( 'rdoc' , '~> 4.1' )
|
13
13
|
spec.add_development_dependency( 'json' , '~> 1.7.7' )
|
14
|
-
spec.add_development_dependency( 'rake-compiler', '~> 0.
|
14
|
+
spec.add_development_dependency( 'rake-compiler', '~> 0.9' )
|
15
15
|
|
16
16
|
spec.extensions.concat This.extension_conf_files
|
17
|
+
spec.license = "ISC"
|
17
18
|
end
|
18
19
|
|
19
20
|
This.java_gemspec( This.ruby_gemspec ) do |spec|
|
data/ext/hitimes/c/extconf.rb
CHANGED
@@ -9,6 +9,13 @@ elsif RbConfig::CONFIG['host_os'] =~ /win32/ or RbConfig::CONFIG['host_os'] =~ /
|
|
9
9
|
else
|
10
10
|
if have_library("rt", "clock_gettime") then
|
11
11
|
$CFLAGS += " -DUSE_INSTANT_CLOCK_GETTIME=1"
|
12
|
+
elsif have_library("c", "clock_gettime") then
|
13
|
+
$CFLAGS += " -DUSE_INSTANT_CLOCK_GETTIME=1"
|
14
|
+
else
|
15
|
+
raise NotImplementedError, <<-_
|
16
|
+
Unable to find the function 'clock_gettime' in either libc or librt.
|
17
|
+
Please file an issue at https://github.com/copiousfreetime/hitimes.
|
18
|
+
_
|
12
19
|
end
|
13
20
|
end
|
14
21
|
|
data/lib/hitimes/version.rb
CHANGED
data/spec/hitimes_spec.rb
CHANGED
@@ -5,10 +5,10 @@ describe Hitimes do
|
|
5
5
|
d = Hitimes.measure do
|
6
6
|
sleep 0.2
|
7
7
|
end
|
8
|
-
d.
|
8
|
+
d.must_be_close_to(0.2, 0.002)
|
9
9
|
end
|
10
10
|
|
11
11
|
it "raises an error if measure is called with no block" do
|
12
|
-
lambda{ Hitimes.measure }.
|
12
|
+
lambda{ Hitimes.measure }.must_raise( Hitimes::Error )
|
13
13
|
end
|
14
14
|
end
|
data/spec/interval_spec.rb
CHANGED
@@ -3,54 +3,54 @@ require "spec_helper"
|
|
3
3
|
describe Hitimes::Interval do
|
4
4
|
it "raises an error if duration is called on a non-started interval" do
|
5
5
|
i = Hitimes::Interval.new
|
6
|
-
lambda{ i.duration }.
|
6
|
+
lambda{ i.duration }.must_raise( Hitimes::Error, /\AAttempt to report a duration on an interval that has not started\Z/ )
|
7
7
|
end
|
8
8
|
|
9
9
|
it "raises an error if stop is called on a non-started interval" do
|
10
10
|
i = Hitimes::Interval.new
|
11
|
-
lambda { i.stop }.
|
11
|
+
lambda { i.stop }.must_raise( Hitimes::Error, /\AAttempt to stop an interval that has not started\Z/ )
|
12
12
|
end
|
13
13
|
|
14
14
|
it "knows if it has been started" do
|
15
15
|
i = Hitimes::Interval.new
|
16
|
-
i.
|
16
|
+
i.started?.must_equal false
|
17
17
|
|
18
18
|
i.start
|
19
|
-
i.
|
19
|
+
i.started?.must_equal true
|
20
20
|
end
|
21
21
|
|
22
22
|
it "knows if it has been stopped" do
|
23
23
|
i = Hitimes::Interval.new
|
24
24
|
i.start
|
25
|
-
i.
|
25
|
+
i.stopped?.must_equal false
|
26
26
|
i.stop
|
27
|
-
i.
|
27
|
+
i.stopped?.must_equal true
|
28
28
|
end
|
29
29
|
|
30
30
|
it "knows if it is currently running" do
|
31
31
|
i = Hitimes::Interval.new
|
32
|
-
i.
|
32
|
+
i.running?.must_equal false
|
33
33
|
i.start
|
34
|
-
i.
|
34
|
+
i.running?.must_equal true
|
35
35
|
i.stop
|
36
|
-
i.
|
36
|
+
i.running?.must_equal false
|
37
37
|
end
|
38
38
|
|
39
39
|
it "can time a block of code" do
|
40
40
|
d = Hitimes::Interval.measure do
|
41
41
|
sleep 0.2
|
42
42
|
end
|
43
|
-
d.
|
43
|
+
d.must_be_close_to(0.2, 0.002)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "raises an error if measure is called with no block" do
|
47
|
-
lambda{ Hitimes::Interval.measure }.
|
47
|
+
lambda{ Hitimes::Interval.measure }.must_raise( Hitimes::Error, /\ANo block given to Interval.measure\Z/ )
|
48
48
|
end
|
49
49
|
|
50
50
|
it "creates an interval via #now" do
|
51
51
|
i = Hitimes::Interval.now
|
52
|
-
i.
|
53
|
-
i.
|
52
|
+
i.started?.must_equal true
|
53
|
+
i.stopped?.must_equal false
|
54
54
|
end
|
55
55
|
|
56
56
|
it "calling duration multiple times returns successivly grater durations" do
|
@@ -58,33 +58,33 @@ describe Hitimes::Interval do
|
|
58
58
|
i.start
|
59
59
|
y = i.duration
|
60
60
|
z = i.duration
|
61
|
-
z.
|
61
|
+
z.must_be :>, y
|
62
62
|
end
|
63
63
|
|
64
64
|
it "calling start multiple times on has no effect after the first call" do
|
65
65
|
i = Hitimes::Interval.new
|
66
|
-
i.start.
|
66
|
+
i.start.must_equal true
|
67
67
|
x = i.start_instant
|
68
|
-
i.start_instant.
|
69
|
-
i.start.
|
70
|
-
x.
|
68
|
+
i.start_instant.must_be :>, 0
|
69
|
+
i.start.must_equal false
|
70
|
+
x.must_equal i.start_instant
|
71
71
|
end
|
72
72
|
|
73
73
|
it "returns the duration on the first call to stop" do
|
74
74
|
i = Hitimes::Interval.now
|
75
75
|
d = i.stop
|
76
|
-
d.
|
76
|
+
d.must_be_instance_of( Float )
|
77
77
|
end
|
78
78
|
|
79
79
|
it "calling stop multiple times on has no effect after the first call" do
|
80
80
|
i = Hitimes::Interval.new
|
81
|
-
i.start.
|
81
|
+
i.start.must_equal true
|
82
82
|
i.stop
|
83
83
|
|
84
84
|
x = i.stop_instant
|
85
|
-
i.stop_instant.
|
86
|
-
i.stop.
|
87
|
-
x.
|
85
|
+
i.stop_instant.must_be :>, 0
|
86
|
+
i.stop.must_equal false
|
87
|
+
x.must_equal i.stop_instant
|
88
88
|
|
89
89
|
end
|
90
90
|
|
@@ -93,26 +93,26 @@ describe Hitimes::Interval do
|
|
93
93
|
i.start
|
94
94
|
x = i.stop
|
95
95
|
y = i.duration
|
96
|
-
i.stop.
|
96
|
+
i.stop.must_equal false
|
97
97
|
|
98
98
|
z = i.duration
|
99
99
|
|
100
|
-
x.
|
101
|
-
x.
|
100
|
+
x.must_equal y
|
101
|
+
x.must_equal z
|
102
102
|
|
103
|
-
y.
|
103
|
+
y.must_equal z
|
104
104
|
end
|
105
105
|
|
106
106
|
it "can return how much time has elapsed from the start without stopping the interval" do
|
107
107
|
i = Hitimes::Interval.new
|
108
108
|
i.start
|
109
109
|
x = i.duration_so_far
|
110
|
-
i.
|
110
|
+
i.running?.must_equal true
|
111
111
|
y = i.duration_so_far
|
112
112
|
i.stop
|
113
|
-
x.
|
114
|
-
x.
|
115
|
-
y.
|
113
|
+
x.must_be :<, y
|
114
|
+
x.must_be :<, i.duration
|
115
|
+
y.must_be :<, i.duration
|
116
116
|
end
|
117
117
|
|
118
118
|
describe "#split" do
|
@@ -121,14 +121,14 @@ describe Hitimes::Interval do
|
|
121
121
|
i = Hitimes::Interval.new
|
122
122
|
i.start
|
123
123
|
i2 = i.split
|
124
|
-
i.object_id.
|
124
|
+
i.object_id.wont_equal i2.object_id
|
125
125
|
end
|
126
126
|
|
127
127
|
it "with the stop instant equivialent to the previous Interval's start instant" do
|
128
128
|
i = Hitimes::Interval.new
|
129
129
|
i.start
|
130
130
|
i2 = i.split
|
131
|
-
i.stop_instant.
|
131
|
+
i.stop_instant.must_equal i2.start_instant
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
data/spec/metric_spec.rb
CHANGED
@@ -6,22 +6,22 @@ describe Hitimes::Metric do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'has a name' do
|
9
|
-
@metric.name.
|
9
|
+
@metric.name.must_equal "testing"
|
10
10
|
end
|
11
11
|
|
12
12
|
it "has associated data from initialization" do
|
13
13
|
m = Hitimes::Metric.new( "more-data", 'foo' => 'bar', 'this' => 'that' )
|
14
|
-
m.additional_data['foo'].
|
15
|
-
m.additional_data['this'].
|
14
|
+
m.additional_data['foo'].must_equal 'bar'
|
15
|
+
m.additional_data['this'].must_equal 'that'
|
16
16
|
|
17
17
|
m = Hitimes::Metric.new( "more-data", { 'foo' => 'bar', 'this' => 'that' } )
|
18
|
-
m.additional_data['foo'].
|
19
|
-
m.additional_data['this'].
|
18
|
+
m.additional_data['foo'].must_equal 'bar'
|
19
|
+
m.additional_data['this'].must_equal 'that'
|
20
20
|
end
|
21
21
|
|
22
22
|
it "initially has no sampling times" do
|
23
|
-
@metric.sampling_start_time.
|
24
|
-
@metric.sampling_stop_time.
|
23
|
+
@metric.sampling_start_time.must_be_nil
|
24
|
+
@metric.sampling_stop_time.must_be_nil
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
data/spec/mutex_stats_spec.rb
CHANGED
@@ -19,18 +19,18 @@ describe Hitimes::MutexedStats do
|
|
19
19
|
if (not defined? RUBY_ENGINE) or (RUBY_ENGINE == "ruby") then
|
20
20
|
it "Hitimes::Stats is threadsafe" do
|
21
21
|
stats = run_with_scissors( ::Hitimes::Stats.new, @threads, @iters )
|
22
|
-
stats.count.
|
22
|
+
stats.count.must_equal @final_value
|
23
23
|
end
|
24
24
|
else
|
25
25
|
it "Hitimes::Stats is not threadsafe" do
|
26
26
|
stats = run_with_scissors( ::Hitimes::Stats.new, @threads, @iters )
|
27
|
-
stats.count.
|
27
|
+
stats.count.wont_equal @final_value
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
it "has a threadsafe update" do
|
32
32
|
stats = run_with_scissors( ::Hitimes::MutexedStats.new, @threads, @iters )
|
33
|
-
stats.count.
|
33
|
+
stats.count.must_equal @final_value
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|
data/spec/paths_spec.rb
CHANGED
@@ -2,10 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Hitimes::Paths do
|
4
4
|
it "can access the root dir of the project" do
|
5
|
-
Hitimes::Paths.root_dir.
|
5
|
+
Hitimes::Paths.root_dir.must_equal File.expand_path( File.join( File.dirname( __FILE__ ), ".." ) ) + ::File::SEPARATOR
|
6
6
|
end
|
7
7
|
|
8
8
|
it "can access the lib path of the project" do
|
9
|
-
Hitimes::Paths.lib_path.
|
9
|
+
Hitimes::Paths.lib_path.must_equal File.expand_path( File.join( File.dirname( __FILE__ ), "..", "lib" ) ) + ::File::SEPARATOR
|
10
10
|
end
|
11
11
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/stats_spec.rb
CHANGED
@@ -10,64 +10,64 @@ describe Hitimes::Stats do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "is initialized with 0 values" do
|
13
|
-
@stats.count.
|
14
|
-
@stats.min.
|
15
|
-
@stats.max.
|
16
|
-
@stats.sum.
|
17
|
-
@stats.rate.
|
13
|
+
@stats.count.must_equal 0
|
14
|
+
@stats.min.must_equal 0.0
|
15
|
+
@stats.max.must_equal 0.0
|
16
|
+
@stats.sum.must_equal 0.0
|
17
|
+
@stats.rate.must_equal 0.0
|
18
18
|
end
|
19
19
|
|
20
20
|
it "calculates the mean correctly" do
|
21
|
-
@full_stats.mean.
|
21
|
+
@full_stats.mean.must_equal 2.0
|
22
22
|
end
|
23
23
|
|
24
24
|
it "calculates the rate correctly" do
|
25
|
-
@full_stats.rate.
|
25
|
+
@full_stats.rate.must_equal 0.5
|
26
26
|
end
|
27
27
|
|
28
28
|
it "tracks the maximum value" do
|
29
|
-
@full_stats.max.
|
29
|
+
@full_stats.max.must_equal 3.0
|
30
30
|
end
|
31
31
|
|
32
32
|
it "tracks the minimum value" do
|
33
|
-
@full_stats.min.
|
33
|
+
@full_stats.min.must_equal 1.0
|
34
34
|
end
|
35
35
|
|
36
36
|
it "tracks the count" do
|
37
|
-
@full_stats.count.
|
37
|
+
@full_stats.count.must_equal 3
|
38
38
|
end
|
39
39
|
|
40
40
|
it "tracks the sum" do
|
41
|
-
@full_stats.sum.
|
41
|
+
@full_stats.sum.must_equal 6.0
|
42
42
|
end
|
43
43
|
|
44
44
|
it "calculates the standard deviation" do
|
45
|
-
@full_stats.stddev.
|
45
|
+
@full_stats.stddev.must_equal 1.0
|
46
46
|
end
|
47
47
|
|
48
48
|
it "calculates the sum of squares " do
|
49
|
-
@full_stats.sumsq.
|
49
|
+
@full_stats.sumsq.must_equal 14.0
|
50
50
|
end
|
51
51
|
|
52
52
|
describe "#to_hash " do
|
53
53
|
it "converts to a Hash" do
|
54
54
|
h = @full_stats.to_hash
|
55
|
-
h.size.
|
56
|
-
h.keys.sort.
|
55
|
+
h.size.must_equal ::Hitimes::Stats::STATS.size
|
56
|
+
h.keys.sort.must_equal ::Hitimes::Stats::STATS
|
57
57
|
end
|
58
58
|
|
59
59
|
it "converts to a limited Hash if given arguments" do
|
60
60
|
h = @full_stats.to_hash( "min", "max", "mean" )
|
61
|
-
h.size.
|
62
|
-
h.keys.sort.
|
61
|
+
h.size.must_equal 3
|
62
|
+
h.keys.sort.must_equal %w[ max mean min ]
|
63
63
|
|
64
64
|
h = @full_stats.to_hash( %w[ count rate ] )
|
65
|
-
h.size.
|
66
|
-
h.keys.sort.
|
65
|
+
h.size.must_equal 2
|
66
|
+
h.keys.sort.must_equal %w[ count rate ]
|
67
67
|
end
|
68
68
|
|
69
69
|
it "raises NoMethodError if an invalid stat is used" do
|
70
|
-
lambda { @full_stats.to_hash( "wibble" ) }.
|
70
|
+
lambda { @full_stats.to_hash( "wibble" ) }.must_raise( NoMethodError )
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -75,24 +75,24 @@ describe Hitimes::Stats do
|
|
75
75
|
it "converts to a json string" do
|
76
76
|
j = @full_stats.to_json
|
77
77
|
h = JSON.parse( j )
|
78
|
-
h.size.
|
79
|
-
h.keys.sort.
|
78
|
+
h.size.must_equal ::Hitimes::Stats::STATS.size
|
79
|
+
h.keys.sort.must_equal ::Hitimes::Stats::STATS
|
80
80
|
end
|
81
81
|
|
82
82
|
it "converts to a limited Hash if given arguments" do
|
83
83
|
j = @full_stats.to_json( "min", "max", "mean" )
|
84
84
|
h = JSON.parse( j )
|
85
|
-
h.size.
|
86
|
-
h.keys.sort.
|
85
|
+
h.size.must_equal 3
|
86
|
+
h.keys.sort.must_equal %w[ max mean min ]
|
87
87
|
|
88
88
|
j = @full_stats.to_json( %w[ count rate ] )
|
89
89
|
h = JSON.parse( j )
|
90
|
-
h.size.
|
91
|
-
h.keys.sort.
|
90
|
+
h.size.must_equal 2
|
91
|
+
h.keys.sort.must_equal %w[ count rate ]
|
92
92
|
end
|
93
93
|
|
94
94
|
it "raises NoMethodError if an invalid stat is used" do
|
95
|
-
lambda { @full_stats.to_json( "wibble" ) }.
|
95
|
+
lambda { @full_stats.to_json( "wibble" ) }.must_raise( NoMethodError )
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
data/spec/timed_metric_spec.rb
CHANGED
@@ -6,90 +6,90 @@ describe Hitimes::TimedMetric do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it "knows if it is running or not" do
|
9
|
-
@tm.
|
9
|
+
@tm.running?.must_equal false
|
10
10
|
@tm.start
|
11
|
-
@tm.
|
11
|
+
@tm.running?.must_equal true
|
12
12
|
@tm.stop
|
13
|
-
@tm.
|
13
|
+
@tm.running?.must_equal false
|
14
14
|
end
|
15
15
|
|
16
16
|
it "#split returns the last duration and the timer is still running" do
|
17
17
|
@tm.start
|
18
18
|
d = @tm.split
|
19
|
-
@tm.
|
20
|
-
d.
|
21
|
-
@tm.count.
|
22
|
-
@tm.duration.
|
19
|
+
@tm.running?.must_equal true
|
20
|
+
d.must_be :>, 0
|
21
|
+
@tm.count.must_equal 1
|
22
|
+
@tm.duration.must_equal d
|
23
23
|
end
|
24
24
|
|
25
25
|
it "#stop returns false if called more than once in a row" do
|
26
26
|
@tm.start
|
27
|
-
@tm.stop.
|
28
|
-
@tm.stop.
|
27
|
+
@tm.stop.must_be :>, 0
|
28
|
+
@tm.stop.must_equal false
|
29
29
|
end
|
30
30
|
|
31
31
|
it "does not count a currently running interval as an interval in calculations" do
|
32
32
|
@tm.start
|
33
|
-
@tm.count.
|
33
|
+
@tm.count.must_equal 0
|
34
34
|
@tm.split
|
35
|
-
@tm.count.
|
35
|
+
@tm.count.must_equal 1
|
36
36
|
end
|
37
37
|
|
38
38
|
it "#split called on a stopped timer does nothing" do
|
39
39
|
@tm.start
|
40
40
|
@tm.stop
|
41
|
-
@tm.split.
|
41
|
+
@tm.split.must_equal false
|
42
42
|
end
|
43
43
|
|
44
44
|
it "calculates the mean of the durations" do
|
45
45
|
2.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
46
|
-
@tm.mean.
|
46
|
+
@tm.mean.must_be_close_to(0.05, 0.002)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "calculates the rate of the counts " do
|
50
50
|
5.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
51
|
-
@tm.rate.
|
51
|
+
@tm.rate.must_be_close_to(20.00, 0.5)
|
52
52
|
end
|
53
53
|
|
54
54
|
|
55
55
|
it "calculates the stddev of the durations" do
|
56
56
|
3.times { |x| @tm.start ; sleep(0.05 * x) ; @tm.stop }
|
57
|
-
@tm.stddev.
|
57
|
+
@tm.stddev.must_be_close_to(0.05)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "returns 0.0 for stddev if there is no data" do
|
61
|
-
@tm.stddev.
|
61
|
+
@tm.stddev.must_equal 0.0
|
62
62
|
end
|
63
63
|
|
64
64
|
it "keeps track of the min value" do
|
65
65
|
2.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
66
|
-
@tm.min.
|
66
|
+
@tm.min.must_be_close_to(0.05, 0.01)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "keeps track of the max value" do
|
70
70
|
2.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
71
|
-
@tm.max.
|
71
|
+
@tm.max.must_be_close_to(0.05, 0.01)
|
72
72
|
end
|
73
73
|
|
74
74
|
it "keeps track of the sum value" do
|
75
75
|
2.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
76
|
-
@tm.sum.
|
76
|
+
@tm.sum.must_be_close_to(0.10, 0.01)
|
77
77
|
end
|
78
78
|
|
79
79
|
it "keeps track of the sum of squars value" do
|
80
80
|
3.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
81
|
-
@tm.sumsq.
|
81
|
+
@tm.sumsq.must_be_close_to(0.0075)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "keeps track of the minimum start time of all the intervals" do
|
85
85
|
f1 = Time.now.gmtime.to_f * 1_000_000
|
86
86
|
5.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
87
87
|
f2 = Time.now.gmtime.to_f * 1_000_000
|
88
|
-
@tm.sampling_start_time.
|
89
|
-
@tm.sampling_start_time.
|
88
|
+
@tm.sampling_start_time.must_be :>=, f1
|
89
|
+
@tm.sampling_start_time.must_be :<, f2
|
90
90
|
# distance from now to start time should be greater than the distance from
|
91
91
|
# the start to the min start_time
|
92
|
-
(f2 - @tm.sampling_start_time).
|
92
|
+
(f2 - @tm.sampling_start_time).must_be :>, ( @tm.sampling_start_time - f1 )
|
93
93
|
end
|
94
94
|
|
95
95
|
it "keeps track of the last stop time of all the intervals" do
|
@@ -98,57 +98,57 @@ describe Hitimes::TimedMetric do
|
|
98
98
|
5.times { @tm.start ; sleep 0.05 ; @tm.stop }
|
99
99
|
sleep 0.01
|
100
100
|
f2 = Time.now.gmtime.to_f * 1_000_000
|
101
|
-
@tm.sampling_stop_time.
|
102
|
-
@tm.sampling_stop_time.
|
101
|
+
@tm.sampling_stop_time.must_be :>, f1
|
102
|
+
@tm.sampling_stop_time.must_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
|
-
(f2 - @tm.sampling_stop_time).
|
105
|
+
(f2 - @tm.sampling_stop_time).must_be :<, ( @tm.sampling_stop_time - f1 )
|
106
106
|
end
|
107
107
|
|
108
108
|
it "can create an already running timer" do
|
109
109
|
t = Hitimes::TimedMetric.now( 'already-running' )
|
110
|
-
t.
|
110
|
+
t.running?.must_equal true
|
111
111
|
end
|
112
112
|
|
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.
|
117
|
-
t.count.
|
116
|
+
t.duration.must_be_close_to(0.15, 0.01)
|
117
|
+
t.count.must_equal 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.
|
124
|
-
x.
|
123
|
+
t.duration.must_be_close_to(0.05, 0.002)
|
124
|
+
x.must_equal 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'].
|
131
|
+
h['name'].must_equal "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'].
|
137
|
-
h['additional_data'].size.
|
136
|
+
h['additional_data'].must_equal Hash.new
|
137
|
+
h['additional_data'].size.must_equal 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'].
|
143
|
+
h['sum'].must_be_close_to(0.45, 0.01)
|
144
144
|
end
|
145
145
|
|
146
146
|
fields = ::Hitimes::Stats::STATS.dup + %w[ name additional_data sampling_start_time sampling_stop_time ]
|
147
147
|
fields.each do |f|
|
148
|
-
it "
|
148
|
+
it "has a value for #{f}" do
|
149
149
|
@tm.measure { sleep 0.001 }
|
150
150
|
h = @tm.to_hash
|
151
|
-
h[f].
|
151
|
+
h[f].wont_be_nil
|
152
152
|
end
|
153
153
|
end
|
154
154
|
end
|
@@ -6,100 +6,100 @@ describe Hitimes::TimedValueMetric do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it "knows if it is running or not" do
|
9
|
-
@tm.
|
9
|
+
@tm.running?.must_equal false
|
10
10
|
@tm.start
|
11
|
-
@tm.
|
11
|
+
@tm.running?.must_equal true
|
12
12
|
@tm.stop( 1 )
|
13
|
-
@tm.
|
13
|
+
@tm.running?.must_equal false
|
14
14
|
end
|
15
15
|
|
16
16
|
it "#split returns the last duration and the timer is still running" do
|
17
17
|
@tm.start
|
18
18
|
d = @tm.split( 1 )
|
19
|
-
@tm.
|
20
|
-
d.
|
21
|
-
@tm.value_stats.count.
|
22
|
-
@tm.timed_stats.count.
|
23
|
-
@tm.duration.
|
19
|
+
@tm.running?.must_equal true
|
20
|
+
d.must_be :>, 0
|
21
|
+
@tm.value_stats.count.must_equal 1
|
22
|
+
@tm.timed_stats.count.must_equal 1
|
23
|
+
@tm.duration.must_equal d
|
24
24
|
end
|
25
25
|
|
26
26
|
it "#stop returns false if called more than once in a row" do
|
27
27
|
@tm.start
|
28
|
-
@tm.stop( 1 ).
|
29
|
-
@tm.stop( 1 ).
|
28
|
+
@tm.stop( 1 ).must_be :>, 0
|
29
|
+
@tm.stop( 1 ).must_equal false
|
30
30
|
end
|
31
31
|
|
32
32
|
it "does not count a currently running interval as an interval in calculations" do
|
33
33
|
@tm.start
|
34
|
-
@tm.value_stats.count.
|
35
|
-
@tm.timed_stats.count.
|
34
|
+
@tm.value_stats.count.must_equal 0
|
35
|
+
@tm.timed_stats.count.must_equal 0
|
36
36
|
@tm.split( 1 )
|
37
|
-
@tm.value_stats.count.
|
38
|
-
@tm.timed_stats.count.
|
37
|
+
@tm.value_stats.count.must_equal 1
|
38
|
+
@tm.timed_stats.count.must_equal 1
|
39
39
|
end
|
40
40
|
|
41
41
|
it "#split called on a stopped timer does nothing" do
|
42
42
|
@tm.start
|
43
43
|
@tm.stop( 1 )
|
44
|
-
@tm.split( 1 ).
|
44
|
+
@tm.split( 1 ).must_equal false
|
45
45
|
end
|
46
46
|
|
47
47
|
it "calculates the mean of the durations" do
|
48
48
|
3.times { |x| @tm.start ; sleep 0.05 ; @tm.stop(x) }
|
49
|
-
@tm.timed_stats.mean.
|
50
|
-
@tm.value_stats.mean.
|
49
|
+
@tm.timed_stats.mean.must_be_close_to(0.05, 0.01)
|
50
|
+
@tm.value_stats.mean.must_equal 1.00
|
51
51
|
end
|
52
52
|
|
53
53
|
it "calculates the rate of the counts " do
|
54
54
|
5.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
55
|
-
@tm.rate.
|
55
|
+
@tm.rate.must_be_close_to(40.0, 1.0)
|
56
56
|
end
|
57
57
|
|
58
58
|
|
59
59
|
it "calculates the stddev of the durations" do
|
60
60
|
3.times { |x| @tm.start ; sleep(0.05 * x) ; @tm.stop(x) }
|
61
|
-
@tm.timed_stats.stddev.
|
62
|
-
@tm.value_stats.stddev.
|
61
|
+
@tm.timed_stats.stddev.must_be_close_to(0.05, 0.001)
|
62
|
+
@tm.value_stats.stddev.must_equal 1.0
|
63
63
|
end
|
64
64
|
|
65
65
|
it "returns 0.0 for stddev if there is no data" do
|
66
|
-
@tm.timed_stats.stddev.
|
67
|
-
@tm.value_stats.stddev.
|
66
|
+
@tm.timed_stats.stddev.must_equal 0.0
|
67
|
+
@tm.value_stats.stddev.must_equal 0.0
|
68
68
|
end
|
69
69
|
|
70
70
|
it "keeps track of the min value" do
|
71
71
|
3.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
72
|
-
@tm.timed_stats.min.
|
73
|
-
@tm.value_stats.min.
|
72
|
+
@tm.timed_stats.min.must_be_close_to( 0.05, 0.003 )
|
73
|
+
@tm.value_stats.min.must_equal 0
|
74
74
|
end
|
75
75
|
|
76
76
|
it "keeps track of the max value" do
|
77
77
|
3.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
78
|
-
@tm.timed_stats.max.
|
79
|
-
@tm.value_stats.max.
|
78
|
+
@tm.timed_stats.max.must_be_close_to( 0.05, 0.003 )
|
79
|
+
@tm.value_stats.max.must_equal 2
|
80
80
|
end
|
81
81
|
|
82
82
|
it "keeps track of the sum value" do
|
83
83
|
3.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
84
|
-
@tm.timed_stats.sum.
|
85
|
-
@tm.value_stats.sum.
|
84
|
+
@tm.timed_stats.sum.must_be_close_to( 0.15, 0.01 )
|
85
|
+
@tm.value_stats.sum.must_equal 3
|
86
86
|
end
|
87
87
|
|
88
88
|
it "keeps track of the sum of squares value" do
|
89
89
|
3.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
90
|
-
@tm.timed_stats.sumsq.
|
91
|
-
@tm.value_stats.sumsq.
|
90
|
+
@tm.timed_stats.sumsq.must_be_close_to(0.0075, 0.0005)
|
91
|
+
@tm.value_stats.sumsq.must_equal 5
|
92
92
|
end
|
93
93
|
|
94
94
|
it "keeps track of the minimum start time of all the intervals" do
|
95
95
|
f1 = Time.now.gmtime.to_f * 1000000
|
96
96
|
5.times { @tm.start ; sleep 0.05 ; @tm.stop( 1 ) }
|
97
97
|
f2 = Time.now.gmtime.to_f * 1000000
|
98
|
-
@tm.sampling_start_time.
|
99
|
-
@tm.sampling_start_time.
|
98
|
+
@tm.sampling_start_time.must_be :>=, f1
|
99
|
+
@tm.sampling_start_time.must_be :<, f2
|
100
100
|
# distance from now to start time should be greater than the distance from
|
101
101
|
# the start to the min start_time
|
102
|
-
(f2 - @tm.sampling_start_time).
|
102
|
+
(f2 - @tm.sampling_start_time).must_be :>, ( @tm.sampling_start_time - f1 )
|
103
103
|
end
|
104
104
|
|
105
105
|
it "keeps track of the last stop time of all the intervals" do
|
@@ -107,64 +107,64 @@ describe Hitimes::TimedValueMetric do
|
|
107
107
|
5.times { @tm.start ; sleep 0.05 ; @tm.stop( 1 ) }
|
108
108
|
sleep 0.05
|
109
109
|
f2 = Time.now.gmtime.to_f * 1_000_000
|
110
|
-
@tm.sampling_stop_time.
|
111
|
-
@tm.sampling_stop_time.
|
110
|
+
@tm.sampling_stop_time.must_be :>, f1
|
111
|
+
@tm.sampling_stop_time.must_be :<=, f2
|
112
112
|
# distance from now to max stop time time should be less than the distance
|
113
113
|
# from the start to the max stop time
|
114
|
-
(f2 - @tm.sampling_stop_time).
|
114
|
+
(f2 - @tm.sampling_stop_time).must_be :<, ( @tm.sampling_stop_time - f1 )
|
115
115
|
end
|
116
116
|
|
117
117
|
it "can create an already running timer" do
|
118
118
|
t = Hitimes::TimedValueMetric.now( 'already-running' )
|
119
|
-
t.
|
119
|
+
t.running?.must_equal true
|
120
120
|
end
|
121
121
|
|
122
122
|
it "can measure a block of code from an instance" do
|
123
123
|
t = Hitimes::TimedValueMetric.new( 'measure a block' )
|
124
124
|
3.times { t.measure( 1 ) { sleep 0.05 } }
|
125
|
-
t.duration.
|
126
|
-
t.timed_stats.count.
|
127
|
-
t.value_stats.count.
|
125
|
+
t.duration.must_be_close_to(0.15, 0.004)
|
126
|
+
t.timed_stats.count.must_equal 3
|
127
|
+
t.value_stats.count.must_equal 3
|
128
128
|
end
|
129
129
|
|
130
130
|
it "returns the value of the block when measuring" do
|
131
131
|
t = Hitimes::TimedValueMetric.new( 'measure a block' )
|
132
132
|
x = t.measure( 42 ) { sleep 0.05; 42 }
|
133
|
-
t.duration.
|
134
|
-
x.
|
133
|
+
t.duration.must_be_close_to(0.05, 0.002)
|
134
|
+
x.must_equal 42
|
135
135
|
end
|
136
136
|
|
137
137
|
describe "#to_hash" do
|
138
138
|
|
139
139
|
it "has name value" do
|
140
140
|
h = @tm.to_hash
|
141
|
-
h['name'].
|
141
|
+
h['name'].must_equal "test-timed-value-metric"
|
142
142
|
end
|
143
143
|
|
144
144
|
it "has an empty has for additional_data" do
|
145
145
|
h = @tm.to_hash
|
146
|
-
h['additional_data'].
|
147
|
-
h['additional_data'].size.
|
146
|
+
h['additional_data'].must_equal Hash.new
|
147
|
+
h['additional_data'].size.must_equal 0
|
148
148
|
end
|
149
149
|
|
150
150
|
it "has a rate" do
|
151
151
|
5.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
152
152
|
h = @tm.to_hash
|
153
|
-
h['rate'].
|
153
|
+
h['rate'].must_be_close_to(40.0, 1.0)
|
154
154
|
end
|
155
155
|
|
156
156
|
it "has a unit_count" do
|
157
157
|
5.times { |x| @tm.start ; sleep 0.05 ; @tm.stop( x ) }
|
158
158
|
h = @tm.to_hash
|
159
|
-
h['unit_count'].
|
159
|
+
h['unit_count'].must_equal 10
|
160
160
|
end
|
161
161
|
|
162
162
|
fields = %w[ name additional_data sampling_start_time sampling_stop_time value_stats timed_stats rate unit_count ]
|
163
163
|
fields.each do |f|
|
164
|
-
it "
|
164
|
+
it "has a value for #{f}" do
|
165
165
|
3.times { |x| @tm.measure(x) { sleep 0.001 } }
|
166
166
|
h = @tm.to_hash
|
167
|
-
h[f].
|
167
|
+
h[f].wont_be_nil
|
168
168
|
end
|
169
169
|
end
|
170
170
|
end
|
data/spec/value_metric_spec.rb
CHANGED
@@ -7,50 +7,50 @@ describe Hitimes::ValueMetric do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'has a name' do
|
10
|
-
@metric.name.
|
10
|
+
@metric.name.must_equal "testing"
|
11
11
|
end
|
12
12
|
|
13
13
|
it "has associated data from initialization" do
|
14
14
|
m = Hitimes::ValueMetric.new( "more-data", 'foo' => 'bar', 'this' => 'that' )
|
15
|
-
m.additional_data['foo'].
|
16
|
-
m.additional_data['this'].
|
15
|
+
m.additional_data['foo'].must_equal 'bar'
|
16
|
+
m.additional_data['this'].must_equal 'that'
|
17
17
|
|
18
18
|
m = Hitimes::ValueMetric.new( "more-data", { 'foo' => 'bar', 'this' => 'that' } )
|
19
|
-
m.additional_data['foo'].
|
20
|
-
m.additional_data['this'].
|
19
|
+
m.additional_data['foo'].must_equal 'bar'
|
20
|
+
m.additional_data['this'].must_equal 'that'
|
21
21
|
end
|
22
22
|
|
23
23
|
it "calculates the mean of the measurements" do
|
24
|
-
@metric.mean.
|
24
|
+
@metric.mean.must_equal 4.5
|
25
25
|
end
|
26
26
|
|
27
27
|
it "calculates the stddev of the measurements" do
|
28
|
-
@metric.stddev.
|
28
|
+
@metric.stddev.must_be :>, 0.0
|
29
29
|
end
|
30
30
|
|
31
31
|
it "returns 0.0 for stddev if there is no data" do
|
32
32
|
m = Hitimes::ValueMetric.new('0-data')
|
33
|
-
m.stddev.
|
33
|
+
m.stddev.must_equal 0.0
|
34
34
|
end
|
35
35
|
|
36
36
|
it "keeps track of the sum of data" do
|
37
|
-
@metric.sum.
|
37
|
+
@metric.sum.must_equal 45.0
|
38
38
|
end
|
39
39
|
|
40
40
|
it "keeps track of the sum of squars of data" do
|
41
|
-
@metric.sumsq.
|
41
|
+
@metric.sumsq.must_equal 285.0
|
42
42
|
end
|
43
43
|
|
44
44
|
it "retuns 0.0 for mean if there is no data" do
|
45
|
-
Hitimes::ValueMetric.new('0-data').mean.
|
45
|
+
Hitimes::ValueMetric.new('0-data').mean.must_equal 0.0
|
46
46
|
end
|
47
47
|
|
48
48
|
it "keeps track of the min value" do
|
49
|
-
@metric.min.
|
49
|
+
@metric.min.must_equal 0
|
50
50
|
end
|
51
51
|
|
52
52
|
it "keeps track of the max value" do
|
53
|
-
@metric.max.
|
53
|
+
@metric.max.must_equal 9
|
54
54
|
end
|
55
55
|
|
56
56
|
it "keeps track of the first start time of all the measurements" do
|
@@ -58,11 +58,11 @@ describe Hitimes::ValueMetric do
|
|
58
58
|
f1 = Time.now.gmtime.to_f * 1_000_000
|
59
59
|
10.times{ |x| m.measure( x ); sleep 0.1 }
|
60
60
|
f2 = Time.now.gmtime.to_f * 1_000_000
|
61
|
-
m.sampling_start_time.
|
62
|
-
m.sampling_start_time.
|
61
|
+
m.sampling_start_time.must_be :>=, f1
|
62
|
+
m.sampling_start_time.must_be :<, f2
|
63
63
|
# distance from now to start time should be greater than the distance from
|
64
64
|
# the start to the min start_time
|
65
|
-
(f2 - m.sampling_start_time).
|
65
|
+
(f2 - m.sampling_start_time).must_be :>, ( m.sampling_start_time - f1 )
|
66
66
|
end
|
67
67
|
|
68
68
|
it "keeps track of the last stop time of all the intervals" do
|
@@ -70,37 +70,37 @@ describe Hitimes::ValueMetric do
|
|
70
70
|
f1 = Time.now.gmtime.to_f * 1_000_000
|
71
71
|
10.times {|x| m.measure( x ); sleep 0.1 }
|
72
72
|
f2 = Time.now.gmtime.to_f * 1_000_000
|
73
|
-
m.sampling_stop_time.
|
74
|
-
m.sampling_stop_time.
|
73
|
+
m.sampling_stop_time.must_be :>, f1
|
74
|
+
m.sampling_stop_time.must_be :<=, f2
|
75
75
|
# distance from now to max stop time time should be less than the distance
|
76
76
|
# from the start to the max stop time
|
77
|
-
(f2 - m.sampling_stop_time).
|
77
|
+
(f2 - m.sampling_stop_time).must_be :<, ( m.sampling_stop_time - f1 )
|
78
78
|
end
|
79
79
|
|
80
80
|
describe "#to_hash" do
|
81
81
|
|
82
82
|
it "has name value" do
|
83
83
|
h = @metric.to_hash
|
84
|
-
h['name'].
|
84
|
+
h['name'].must_equal "testing"
|
85
85
|
end
|
86
86
|
|
87
87
|
it "has an empty has for additional_data" do
|
88
88
|
h = @metric.to_hash
|
89
|
-
h['additional_data'].
|
90
|
-
h['additional_data'].size.
|
89
|
+
h['additional_data'].must_equal Hash.new
|
90
|
+
h['additional_data'].size.must_equal 0
|
91
91
|
end
|
92
92
|
|
93
93
|
it "has the right sum" do
|
94
94
|
h = @metric.to_hash
|
95
|
-
h['sum'].
|
95
|
+
h['sum'].must_equal 45
|
96
96
|
end
|
97
97
|
|
98
98
|
fields = ::Hitimes::Stats::STATS.dup + %w[ name additional_data sampling_start_time sampling_stop_time ]
|
99
99
|
fields = fields - [ 'rate' ]
|
100
100
|
fields.each do |f|
|
101
|
-
it "
|
101
|
+
it "has a value for #{f}" do
|
102
102
|
h = @metric.to_hash
|
103
|
-
h[f].
|
103
|
+
h[f].wont_be_nil
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
data/spec/version_spec.rb
CHANGED
data/tasks/default.rake
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# vim: syntax=ruby
|
2
2
|
require 'rake/clean'
|
3
|
+
require 'digest'
|
3
4
|
#------------------------------------------------------------------------------
|
4
5
|
# If you want to Develop on this project just run 'rake develop' and you'll
|
5
6
|
# have all you need to get going. If you want to use bundler for development,
|
@@ -11,7 +12,7 @@ namespace :develop do
|
|
11
12
|
# gemspec.
|
12
13
|
task :default do
|
13
14
|
require 'rubygems/dependency_installer'
|
14
|
-
installer = Gem::DependencyInstaller.new
|
15
|
+
installer = ::Gem::DependencyInstaller.new
|
15
16
|
|
16
17
|
This.set_coverage_gem
|
17
18
|
|
@@ -30,7 +31,9 @@ namespace :develop do
|
|
30
31
|
# Create a Gemfile that just references the gemspec
|
31
32
|
file 'Gemfile' => :gemspec do
|
32
33
|
File.open( "Gemfile", "w+" ) do |f|
|
33
|
-
f.puts
|
34
|
+
f.puts "# DO NOT EDIT - This file is automatically generated"
|
35
|
+
f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
|
36
|
+
f.puts 'source "https://rubygems.org/"'
|
34
37
|
f.puts 'gemspec'
|
35
38
|
end
|
36
39
|
end
|
@@ -53,8 +56,8 @@ begin
|
|
53
56
|
require 'rake/testtask'
|
54
57
|
Rake::TestTask.new( :test ) do |t|
|
55
58
|
t.ruby_opts = %w[ -w -rubygems ]
|
56
|
-
t.libs = %w[ lib spec ]
|
57
|
-
t.pattern = "spec
|
59
|
+
t.libs = %w[ lib spec test ]
|
60
|
+
t.pattern = "{test,spec}/**/{test_*,*_spec}.rb"
|
58
61
|
end
|
59
62
|
|
60
63
|
task :test_requirements
|
@@ -79,7 +82,7 @@ begin
|
|
79
82
|
t.rdoc_files.include( FileList['*.{rdoc,md,txt}'], FileList['ext/**/*.c'],
|
80
83
|
FileList['lib/**/*.rb'] )
|
81
84
|
end
|
82
|
-
rescue LoadError
|
85
|
+
rescue StandardError, LoadError
|
83
86
|
This.task_warning( 'rdoc' )
|
84
87
|
end
|
85
88
|
|
@@ -106,9 +109,9 @@ else
|
|
106
109
|
desc 'Run tests with code coverage'
|
107
110
|
task :coverage do
|
108
111
|
ENV['COVERAGE'] = 'true'
|
109
|
-
Rake::Task[:test].
|
112
|
+
Rake::Task[:test].invoke
|
110
113
|
end
|
111
|
-
CLOBBER << FileList["coverage"]
|
114
|
+
CLOBBER << FileList["coverage"] if File.directory?( "coverage" )
|
112
115
|
rescue LoadError
|
113
116
|
This.task_warning( 'simplecov' )
|
114
117
|
end
|
@@ -222,6 +225,8 @@ task :fixme => "fixme:default"
|
|
222
225
|
desc "Build the #{This.name}.gemspec file"
|
223
226
|
task :gemspec do
|
224
227
|
File.open( This.gemspec_file, "wb+" ) do |f|
|
228
|
+
f.puts "# DO NOT EDIT - This file is automatically generated"
|
229
|
+
f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
|
225
230
|
f.write This.platform_gemspec.to_ruby
|
226
231
|
end
|
227
232
|
end
|
@@ -234,7 +239,7 @@ CLOBBER << FileList["**/*.rbc"]
|
|
234
239
|
|
235
240
|
# The standard gem packaging task, everyone has it.
|
236
241
|
require 'rubygems/package_task'
|
237
|
-
Gem::PackageTask.new( This.platform_gemspec ) do
|
242
|
+
::Gem::PackageTask.new( This.platform_gemspec ) do
|
238
243
|
# nothing
|
239
244
|
end
|
240
245
|
|
data/tasks/this.rb
CHANGED
@@ -25,7 +25,7 @@ class ThisProject
|
|
25
25
|
#
|
26
26
|
# Yields self
|
27
27
|
def initialize(&block)
|
28
|
-
@exclude_from_manifest = %r/\.(git|DS_Store)|^(doc|coverage|pkg|tmp
|
28
|
+
@exclude_from_manifest = %r/\.(git|DS_Store)|^(doc|coverage|pkg|tmp|Gemfile(\.lock)?)|^[^\/]+\.gemspec|\.(swp|jar|bundle|so|rvmrc)$|~$/
|
29
29
|
@gemspecs = Hash.new
|
30
30
|
yield self if block_given?
|
31
31
|
end
|
@@ -132,6 +132,7 @@ class ThisProject
|
|
132
132
|
|
133
133
|
spec.summary = summary
|
134
134
|
spec.description = description
|
135
|
+
spec.license = license
|
135
136
|
|
136
137
|
spec.files = manifest
|
137
138
|
spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
|
@@ -176,7 +177,7 @@ class ThisProject
|
|
176
177
|
if RUBY_VERSION < "1.9.0"
|
177
178
|
platform_gemspec.add_development_dependency( 'rcov', '~> 1.0.0' )
|
178
179
|
else
|
179
|
-
platform_gemspec.add_development_dependency( 'simplecov', '~> 0.
|
180
|
+
platform_gemspec.add_development_dependency( 'simplecov', '~> 0.8.2' )
|
180
181
|
end
|
181
182
|
end
|
182
183
|
|
@@ -195,11 +196,15 @@ class ThisProject
|
|
195
196
|
description_section.first
|
196
197
|
end
|
197
198
|
|
198
|
-
# Internal: Return the full description text from the
|
199
|
+
# Internal: Return the full description text from the README
|
199
200
|
def description
|
200
201
|
description_section.join(" ").tr("\n", ' ').gsub(/[{}]/,'').gsub(/\[[^\]]+\]/,'') # strip rdoc
|
201
202
|
end
|
202
203
|
|
204
|
+
def license
|
205
|
+
"ISC"
|
206
|
+
end
|
207
|
+
|
203
208
|
# Internal: The path to the gemspec file
|
204
209
|
def gemspec_file
|
205
210
|
project_path( "#{ name }.gemspec" )
|
metadata
CHANGED
@@ -1,85 +1,85 @@
|
|
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.2
|
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: 2014-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 10.0
|
19
|
+
version: '10.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 10.0
|
26
|
+
version: '10.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '5.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '5.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rdoc
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '4.
|
47
|
+
version: '4.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '4.
|
54
|
+
version: '4.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: json
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.7.7
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.7.7
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake-compiler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: '0.9'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: '0.9'
|
83
83
|
description: 'Hitimes is a fast, high resolution timer library for recording performance
|
84
84
|
metrics. It uses the appropriate low method calls for each system to get the highest
|
85
85
|
granularity time increments possible. It currently supports any of the following
|
@@ -96,6 +96,7 @@ extra_rdoc_files:
|
|
96
96
|
- Manifest.txt
|
97
97
|
- README.md
|
98
98
|
files:
|
99
|
+
- ".travis.yml"
|
99
100
|
- CONTRIBUTING.md
|
100
101
|
- HISTORY.md
|
101
102
|
- LICENSE
|
@@ -141,29 +142,30 @@ files:
|
|
141
142
|
- tasks/extension.rake
|
142
143
|
- tasks/this.rb
|
143
144
|
homepage: http://github.com/copiousfreetime/hitimes
|
144
|
-
licenses:
|
145
|
+
licenses:
|
146
|
+
- ISC
|
145
147
|
metadata: {}
|
146
148
|
post_install_message:
|
147
149
|
rdoc_options:
|
148
|
-
- --main
|
150
|
+
- "--main"
|
149
151
|
- README.md
|
150
|
-
- --markup
|
152
|
+
- "--markup"
|
151
153
|
- tomdoc
|
152
154
|
require_paths:
|
153
155
|
- lib
|
154
156
|
required_ruby_version: !ruby/object:Gem::Requirement
|
155
157
|
requirements:
|
156
|
-
- -
|
158
|
+
- - ">="
|
157
159
|
- !ruby/object:Gem::Version
|
158
160
|
version: '0'
|
159
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
162
|
requirements:
|
161
|
-
- -
|
163
|
+
- - ">="
|
162
164
|
- !ruby/object:Gem::Version
|
163
165
|
version: '0'
|
164
166
|
requirements: []
|
165
167
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
168
|
+
rubygems_version: 2.2.2
|
167
169
|
signing_key:
|
168
170
|
specification_version: 4
|
169
171
|
summary: Hitimes is a fast, high resolution timer library for recording performance
|