quicky 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- quicky (0.0.1)
4
+ quicky (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- test-unit (2.5.0)
9
+ test-unit (2.5.1)
10
10
 
11
11
  PLATFORMS
12
12
  ruby
@@ -9,7 +9,7 @@ module Quicky
9
9
  def loop(name, x, options={}, &blk)
10
10
  if options[:warmup]
11
11
  options[:warmup].times do |i|
12
- puts "Warming up... #{i}"
12
+ #puts "Warming up... #{i}"
13
13
  yield
14
14
  end
15
15
  end
@@ -18,6 +18,20 @@ module Quicky
18
18
  end
19
19
  end
20
20
 
21
+ # will loop for number of seconds
22
+ def loop_for(name, seconds, options={}, &blk)
23
+ end_at = Time.now + seconds
24
+ if options[:warmup]
25
+ options[:warmup].times do |i|
26
+ #puts "Warming up... #{i}"
27
+ yield
28
+ end
29
+ end
30
+ while Time.now < end_at
31
+ time(name, options, &blk)
32
+ end
33
+ end
34
+
21
35
  def time(name, options={}, &blk)
22
36
  t = Time.now
23
37
  yield
@@ -58,6 +72,11 @@ module Quicky
58
72
  def total_duration
59
73
  @total_duration
60
74
  end
75
+
76
+ def count
77
+ @collector.size
78
+ end
79
+
61
80
  end
62
81
 
63
82
  class TimeResult
@@ -1,3 +1,3 @@
1
1
  module Quicky
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -28,6 +28,17 @@ class TestBasics < TestBase
28
28
  assert quicky.results(:test2).duration >= 1 && quicky.results(:test2).duration < 2
29
29
  assert quicky.results(:test2).total_duration >= 10
30
30
 
31
+ quicky = Quicky::Timer.new
32
+ quicky.loop_for(:test3, 10) do |i|
33
+ puts 'sleeping'
34
+ sleep 0.5
35
+ end
36
+ p quicky.results(:test3).inspect
37
+ p quicky.results(:test3).duration
38
+ p quicky.results.count
39
+ assert quicky.results(:test3).duration >= 0.5 && quicky.results(:test3).duration < 1
40
+ assert quicky.results(:test3).total_duration >= 5
41
+
31
42
  end
32
43
 
33
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quicky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-20 00:00:00.000000000 Z
12
+ date: 2012-07-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit