stella 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/{README.txt → README.textile} +63 -40
  2. data/Rakefile +7 -5
  3. data/bin/stella +1 -1
  4. data/bin/stella.bat +12 -0
  5. data/lib/pcaplet.rb +180 -0
  6. data/lib/stella/adapter/ab.rb +57 -33
  7. data/lib/stella/adapter/base.rb +11 -1
  8. data/lib/stella/adapter/httperf.rb +13 -10
  9. data/lib/stella/adapter/pcap_watcher.rb +221 -0
  10. data/lib/stella/adapter/proxy_watcher.rb +76 -0
  11. data/lib/stella/adapter/siege.rb +28 -11
  12. data/lib/stella/cli/agents.rb +2 -2
  13. data/lib/stella/cli/base.rb +37 -1
  14. data/lib/stella/cli/localtest.rb +1 -2
  15. data/lib/stella/cli/sysinfo.rb +17 -0
  16. data/lib/stella/cli/watch.rb +278 -0
  17. data/lib/stella/cli.rb +23 -11
  18. data/lib/stella/command/base.rb +1 -10
  19. data/lib/stella/command/localtest.rb +43 -23
  20. data/lib/stella/data/domain.rb +75 -0
  21. data/lib/stella/data/http.rb +124 -0
  22. data/lib/stella/logger.rb +16 -5
  23. data/lib/stella/storable.rb +4 -2
  24. data/lib/stella/support.rb +71 -0
  25. data/lib/stella/sysinfo.rb +247 -0
  26. data/lib/stella/test/base.rb +5 -1
  27. data/lib/stella/test/definition.rb +1 -1
  28. data/lib/stella/test/run/summary.rb +14 -4
  29. data/lib/stella/text/resource.rb +0 -1
  30. data/lib/stella.rb +28 -10
  31. data/lib/utils/domainutil.rb +47 -0
  32. data/lib/utils/fileutil.rb +22 -3
  33. data/lib/utils/httputil.rb +184 -128
  34. data/lib/utils/mathutil.rb +20 -7
  35. data/lib/win32/Console/ANSI.rb +305 -0
  36. data/lib/win32/Console.rb +970 -0
  37. data/spec/show-agents_spec.rb +0 -0
  38. data/support/kvm.h +91 -0
  39. data/support/ruby-pcap-takuma-notes.txt +19 -0
  40. data/support/ruby-pcap-takuma-patch.txt +30 -0
  41. data/support/text/en.yaml +26 -3
  42. data/vendor/frylock/README.textile +72 -0
  43. data/vendor/frylock/bin/example +170 -0
  44. data/vendor/frylock/frylock.gemspec +18 -0
  45. data/vendor/frylock/lib/frylock/exceptions.rb +24 -0
  46. data/vendor/frylock/lib/frylock.rb +232 -0
  47. data/vendor/frylock/test/command_test.rb +33 -0
  48. data/vendor/hitimes-0.4.0/HISTORY +28 -0
  49. data/vendor/hitimes-0.4.0/LICENSE.txt +19 -0
  50. data/vendor/hitimes-0.4.0/README +80 -0
  51. data/vendor/hitimes-0.4.0/Rakefile +63 -0
  52. data/vendor/hitimes-0.4.0/examples/benchmarks.rb +86 -0
  53. data/vendor/hitimes-0.4.0/examples/stats.rb +29 -0
  54. data/vendor/hitimes-0.4.0/ext/extconf.rb +15 -0
  55. data/vendor/hitimes-0.4.0/ext/hitimes_ext.c +21 -0
  56. data/vendor/hitimes-0.4.0/ext/hitimes_instant_clock_gettime.c +20 -0
  57. data/vendor/hitimes-0.4.0/ext/hitimes_instant_osx.c +16 -0
  58. data/vendor/hitimes-0.4.0/ext/hitimes_instant_windows.c +27 -0
  59. data/vendor/hitimes-0.4.0/ext/hitimes_interval.c +340 -0
  60. data/vendor/hitimes-0.4.0/ext/hitimes_interval.h +73 -0
  61. data/vendor/hitimes-0.4.0/ext/hitimes_stats.c +242 -0
  62. data/vendor/hitimes-0.4.0/ext/hitimes_stats.h +30 -0
  63. data/vendor/hitimes-0.4.0/ext/rbconfig-mingw.rb +178 -0
  64. data/vendor/hitimes-0.4.0/ext/rbconfig.rb +178 -0
  65. data/vendor/hitimes-0.4.0/gemspec.rb +54 -0
  66. data/vendor/hitimes-0.4.0/lib/hitimes/mutexed_stats.rb +23 -0
  67. data/vendor/hitimes-0.4.0/lib/hitimes/paths.rb +54 -0
  68. data/vendor/hitimes-0.4.0/lib/hitimes/stats.rb +29 -0
  69. data/vendor/hitimes-0.4.0/lib/hitimes/timer.rb +223 -0
  70. data/vendor/hitimes-0.4.0/lib/hitimes/version.rb +42 -0
  71. data/vendor/hitimes-0.4.0/lib/hitimes.rb +24 -0
  72. data/vendor/hitimes-0.4.0/spec/interval_spec.rb +115 -0
  73. data/vendor/hitimes-0.4.0/spec/mutex_stats_spec.rb +34 -0
  74. data/vendor/hitimes-0.4.0/spec/paths_spec.rb +14 -0
  75. data/vendor/hitimes-0.4.0/spec/spec_helper.rb +6 -0
  76. data/vendor/hitimes-0.4.0/spec/stats_spec.rb +72 -0
  77. data/vendor/hitimes-0.4.0/spec/timer_spec.rb +105 -0
  78. data/vendor/hitimes-0.4.0/spec/version_spec.rb +27 -0
  79. data/vendor/hitimes-0.4.0/tasks/announce.rake +39 -0
  80. data/vendor/hitimes-0.4.0/tasks/config.rb +107 -0
  81. data/vendor/hitimes-0.4.0/tasks/distribution.rake +53 -0
  82. data/vendor/hitimes-0.4.0/tasks/documentation.rake +33 -0
  83. data/vendor/hitimes-0.4.0/tasks/extension.rake +64 -0
  84. data/vendor/hitimes-0.4.0/tasks/rspec.rake +31 -0
  85. data/vendor/hitimes-0.4.0/tasks/rubyforge.rake +52 -0
  86. data/vendor/hitimes-0.4.0/tasks/utils.rb +80 -0
  87. data/vendor/useragent/lib/user_agent.rb +1 -1
  88. metadata +87 -8
@@ -0,0 +1,223 @@
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
@@ -0,0 +1,42 @@
1
+ #--
2
+ # Copyright (c) 2008 Jeremy Hinegardner
3
+ # All rights reserved. See LICENSE and/or COPYING for details
4
+ #++
5
+
6
+ module Hitimes
7
+ #
8
+ # module containing all the version information about Hitimes
9
+ #
10
+ module Version
11
+
12
+ MAJOR = 0
13
+ MINOR = 4
14
+ BUILD = 0
15
+
16
+ #
17
+ # :call-seq:
18
+ # Version.to_a -> [ MAJOR, MINOR, BUILD ]
19
+ #
20
+ # Return the version as an array of Integers
21
+ #
22
+ def to_a
23
+ [MAJOR, MINOR, BUILD]
24
+ end
25
+
26
+ #
27
+ # :call-seq:
28
+ # Version.to_s -> MAJOR.MINOR.BUILD
29
+ #
30
+ # Return the version as a String with dotted notation
31
+ #
32
+ def to_s
33
+ to_a.join(".")
34
+ end
35
+
36
+ module_function :to_a
37
+ module_function :to_s
38
+
39
+ STRING = Version.to_s
40
+ end
41
+ VERSION = Version.to_s
42
+ end
@@ -0,0 +1,24 @@
1
+ #--
2
+ # Copyright (c) 2008 Jeremy Hinegardner
3
+ # All rights reserved. See LICENSE and/or COPYING for details.
4
+ #++
5
+
6
+ #
7
+ # The top level module containing the contents of the hitimes library
8
+ #
9
+ # use the library with:
10
+ #
11
+ # require 'hitimes'
12
+ #
13
+ module Hitimes
14
+ #
15
+ # Base class of all errors in Hitimes
16
+ #
17
+ class Error < ::StandardError; end
18
+ end
19
+ require 'hitimes/paths'
20
+ require 'hitimes/version'
21
+ require 'hitimes/stats'
22
+ require 'hitimes/mutexed_stats'
23
+ require 'hitimes/timer'
24
+
@@ -0,0 +1,115 @@
1
+ require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
2
+
3
+ require 'hitimes_ext'
4
+
5
+ describe Hitimes::Interval do
6
+ it "has a 0 duration when newly created" do
7
+ i = Hitimes::Interval.new
8
+ i.duration == 0.0
9
+ end
10
+
11
+ it "knows if it has been started" do
12
+ i = Hitimes::Interval.new
13
+ i.should_not be_started
14
+
15
+ i.start
16
+ i.should be_started
17
+ end
18
+
19
+ it "knows if it has been stopped" do
20
+ i = Hitimes::Interval.new
21
+ i.start
22
+ i.should_not be_stopped
23
+ i.stop
24
+ i.should be_stopped
25
+ end
26
+
27
+ it "knows if it is currently running" do
28
+ i = Hitimes::Interval.new
29
+ i.should_not be_running
30
+ i.start
31
+ i.should be_running
32
+ i.stop
33
+ i.should_not be_running
34
+ end
35
+
36
+ it "can time a block of code" do
37
+ d = Hitimes::Interval.measure do
38
+ sleep 0.2
39
+ end
40
+ d.should be_close(0.2, 0.01)
41
+ end
42
+
43
+ it "raises an error if measure is called with no block" do
44
+ lambda{ Hitimes::Interval.measure }.should raise_error( Hitimes::Error )
45
+ end
46
+
47
+ it "creates an interval via #now" do
48
+ i = Hitimes::Interval.now
49
+ i.should be_started
50
+ i.should_not be_stopped
51
+ end
52
+
53
+ it "calling duration multiple times returns successivly grater durations" do
54
+ i = Hitimes::Interval.new
55
+ i.start
56
+ y = i.duration
57
+ z = i.duration
58
+ z.should > y
59
+ end
60
+
61
+ it "calling start multiple times on has no effect after the first call" do
62
+ i = Hitimes::Interval.new
63
+ i.start.should == true
64
+ x = i.start_instant
65
+ i.start_instant.should > 0
66
+ i.start.should == false
67
+ x.should == i.start_instant
68
+ end
69
+
70
+ it "returns the duration on the first call to stop" do
71
+ i = Hitimes::Interval.now
72
+ d = i.stop
73
+ d.should be_instance_of( Float )
74
+ end
75
+
76
+ it "calling stop multiple times on has no effect after the first call" do
77
+ i = Hitimes::Interval.new
78
+ i.start.should == true
79
+ i.stop
80
+
81
+ x = i.stop_instant
82
+ i.stop_instant.should > 0
83
+ i.stop.should == false
84
+ x.should == i.stop_instant
85
+
86
+ end
87
+
88
+ it "only calculates duration once after stop is called" do
89
+ i = Hitimes::Interval.new
90
+ i.start
91
+ i.stop
92
+ x = i.duration
93
+ y = i.duration
94
+ x.object_id.should == y.object_id
95
+ end
96
+
97
+ describe "#split" do
98
+
99
+ it "creates a new Interval object" do
100
+ i = Hitimes::Interval.new
101
+ i.start
102
+ i2 = i.split
103
+ i.object_id.should_not == i2.object_id
104
+ end
105
+
106
+ it "with the stop instant equivialent to the previous Interval's start instant" do
107
+ i = Hitimes::Interval.new
108
+ i.start
109
+ i2 = i.split
110
+ i.stop_instant.should == i2.start_instant
111
+ end
112
+ end
113
+
114
+ end
115
+
@@ -0,0 +1,34 @@
1
+ require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
2
+
3
+ require 'hitimes_ext'
4
+ require 'hitimes/mutexed_stats'
5
+
6
+ describe Hitimes::MutexedStats do
7
+ before( :each ) do
8
+ @threads = 5
9
+ @iters = 10_000
10
+ @final_value = @threads * @iters
11
+ end
12
+
13
+ def run_with_scissors( stats, threads, iters )
14
+ spool = []
15
+ threads.times do |t|
16
+ spool << Thread.new { iters.times{ stats.update( 1 ) } }
17
+ end
18
+ spool.each { |t| t.join }
19
+ return stats
20
+ end
21
+
22
+ it "is unsafe normally" do
23
+ pending "not for MRI -- not interruptable in this C extension" do
24
+ stats = run_with_scissors( ::Hitimes::Stats.new, @threads, @iters )
25
+ stats.count.should_not == @final_value
26
+ end
27
+ end
28
+
29
+ it "has a threadsafe update" do
30
+ stats = run_with_scissors( ::Hitimes::MutexedStats.new, @threads, @iters )
31
+ stats.count.should == @final_value
32
+ end
33
+
34
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
2
+
3
+ require 'hitimes/paths'
4
+
5
+ describe Hitimes::Paths do
6
+ it "can access the root dir of the project" do
7
+ Hitimes::Paths.root_dir.should == File.expand_path( File.join( File.dirname( __FILE__ ), ".." ) ) + ::File::SEPARATOR
8
+ end
9
+
10
+ it "can access the lib path of the project" do
11
+ Hitimes::Paths.lib_path.should == File.expand_path( File.join( File.dirname( __FILE__ ), "..", "lib" ) ) + ::File::SEPARATOR
12
+ end
13
+
14
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+
4
+ $: << File.expand_path(File.join(File.dirname(__FILE__),"..","ext"))
5
+ $: << File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
6
+
@@ -0,0 +1,72 @@
1
+ require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
2
+
3
+ require 'hitimes_ext'
4
+
5
+ describe Hitimes::Stats do
6
+ before( :each ) do
7
+ @stats = Hitimes::Stats.new
8
+ @full_stats = Hitimes::Stats.new
9
+
10
+ [ 1, 2, 3].each { |i| @full_stats.update( i ) }
11
+ end
12
+
13
+ it "is initialized with 0 values" do
14
+ @stats.count.should == 0
15
+ @stats.min.should == 0.0
16
+ @stats.max.should == 0.0
17
+ @stats.sum.should == 0.0
18
+ @stats.rate.should == 0.0
19
+ end
20
+
21
+ it "calculates the mean correctly" do
22
+ @full_stats.mean.should == 2.0
23
+ end
24
+
25
+ it "calculates the rate correctly" do
26
+ @full_stats.rate.should == 0.5
27
+ end
28
+
29
+ it "tracks the maximum value" do
30
+ @full_stats.max.should == 3.0
31
+ end
32
+
33
+ it "tracks the minimum value" do
34
+ @full_stats.min.should == 1.0
35
+ end
36
+
37
+ it "tracks the count" do
38
+ @full_stats.count.should == 3
39
+ end
40
+
41
+ it "tracks the sum" do
42
+ @full_stats.sum.should == 6.0
43
+ end
44
+
45
+ it "calculates the standard deviation" do
46
+ @full_stats.stddev.should == 1.0
47
+ end
48
+
49
+ describe "#to_hash " do
50
+ it "converts to a Hash" do
51
+ h = @full_stats.to_hash
52
+ h.size.should == ::Hitimes::Stats::STATS.size
53
+ h.keys.sort.should == ::Hitimes::Stats::STATS
54
+ end
55
+
56
+ it "converts to a limited Hash if given arguments" do
57
+ h = @full_stats.to_hash( "min", "max", "mean" )
58
+ h.size.should == 3
59
+ h.keys.sort.should == %w[ max mean min ]
60
+
61
+ h = @full_stats.to_hash( %w[ count rate ] )
62
+ h.size.should == 2
63
+ h.keys.sort.should == %w[ count rate ]
64
+ end
65
+
66
+ it "raises NoMethodError if an invalid stat is used" do
67
+ lambda { @full_stats.to_hash( "wibble" ) }.should raise_error( NoMethodError )
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,105 @@
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
+
@@ -0,0 +1,27 @@
1
+ require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper" ) )
2
+
3
+ describe "Hitimes::Version" do
4
+ it "should have a major numbers that is >= 0" do
5
+ Hitimes::Version::MAJOR.should >= 0
6
+ end
7
+
8
+ it "should have a minor number that is >= 0" do
9
+ Hitimes::Version::MINOR.should >= 0
10
+ end
11
+
12
+ it "should have a tiny number that is >= 0" do
13
+ Hitimes::Version::BUILD.should >= 0
14
+ end
15
+
16
+ it "should have an array representation" do
17
+ Hitimes::Version.to_a.should have(3).items
18
+ end
19
+
20
+ it "should have a string representation" do
21
+ Hitimes::Version.to_s.should match(/\d+\.\d+\.\d+/)
22
+ end
23
+
24
+ it "should be accessable as a constant" do
25
+ Hitimes::VERSION.should match(/\d+\.\d+\.\d+/)
26
+ end
27
+ end
@@ -0,0 +1,39 @@
1
+ require 'tasks/config'
2
+ #-------------------------------------------------------------------------------
3
+ # announcement methods
4
+ #-------------------------------------------------------------------------------
5
+
6
+ proj_config = Configuration.for('project')
7
+ namespace :announce do
8
+ desc "create email for ruby-talk"
9
+ task :email do
10
+ info = Utils.announcement
11
+
12
+ File.open("email.txt", "w") do |mail|
13
+ mail.puts "From: #{proj_config.author} <#{proj_config.email}>"
14
+ mail.puts "To: ruby-talk@ruby-lang.org"
15
+ mail.puts "Date: #{Time.now.rfc2822}"
16
+ mail.puts "Subject: [ANN] #{info[:subject]}"
17
+ mail.puts
18
+ mail.puts info[:title]
19
+ mail.puts
20
+ mail.puts " gem install #{Hitimes::GEM_SPEC.name}"
21
+ mail.puts
22
+ mail.puts info[:urls]
23
+ mail.puts
24
+ mail.puts info[:description]
25
+ mail.puts
26
+ mail.puts "{{ Release notes for Version #{Hitimes::VERSION} }}"
27
+ mail.puts
28
+ mail.puts info[:release_notes]
29
+ mail.puts
30
+ end
31
+ puts "Created the following as email.txt:"
32
+ puts "-" * 72
33
+ puts File.read("email.txt")
34
+ puts "-" * 72
35
+ end
36
+
37
+ CLOBBER << "email.txt"
38
+ end
39
+