tach 0.0.2 → 0.0.3

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/tach.rb +25 -3
  3. data/tach.gemspec +10 -10
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -8,6 +8,16 @@ module Tach
8
8
  Tach::Meter.new(times, &block)
9
9
  end
10
10
 
11
+ def self.tach(name, &block)
12
+ tach_start = Time.now
13
+ instance_eval(&block)
14
+ tach_finish = Time.now
15
+ duration = tach_finish.to_f - tach_start.to_f
16
+ Formatador.display_line
17
+ Formatador.display_line("[bold]#{name}[/] [light_black]#{format("%0.6f", duration)}[/]")
18
+ duration
19
+ end
20
+
11
21
  class Meter
12
22
 
13
23
  def initialize(times = 1, &block)
@@ -18,10 +28,17 @@ module Tach
18
28
  instance_eval(&block)
19
29
 
20
30
  Formatador.display_line
31
+ Formatador.display('[')
21
32
  data = []
22
33
  for name, block in @benchmarks
23
34
  data << { :tach => name, :total => format("%8.6f", run_tach(name, @times, &block)) }
35
+ unless [name, block] == @benchmarks.last
36
+ print(', ')
37
+ STDOUT.flush
38
+ end
24
39
  end
40
+ print("]\n\n")
41
+ STDOUT.flush
25
42
  Formatador.display_table(data, [:tach, :total])
26
43
  Formatador.display_line
27
44
  end
@@ -34,14 +51,15 @@ module Tach
34
51
 
35
52
  def run_tach(name, count, &benchmark)
36
53
  GC::start
37
- Formatador.display_line(name)
54
+ print(name)
55
+ STDOUT.flush
38
56
  tach_start = Time.now
39
57
  for index in 1..count
40
58
  instance_eval(&benchmark)
41
59
  end
42
60
  tach_finish = Time.now
43
- Formatador.display_line
44
- tach_finish - tach_start
61
+ duration = tach_finish.to_f - tach_start.to_f
62
+ duration
45
63
  end
46
64
 
47
65
  end
@@ -50,6 +68,10 @@ end
50
68
 
51
69
  if __FILE__ == $0
52
70
 
71
+ Tach.tach('sleep') do
72
+ sleep(1)
73
+ end
74
+
53
75
  data = 'Content-Length: 100'
54
76
  Tach.meter(100_000) do
55
77
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tach}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["geemus (Wesley Beary)"]
12
- s.date = %q{2010-04-09}
12
+ s.date = %q{2010-11-13}
13
13
  s.description = %q{Simple benchmarking with noticeable progress and pretty results.}
14
14
  s.email = %q{wbeary@engineyard.com}
15
15
  s.extra_rdoc_files = [
@@ -17,14 +17,14 @@ Gem::Specification.new do |s|
17
17
  ]
18
18
  s.files = [
19
19
  ".document",
20
- ".gitignore",
21
- "README.rdoc",
22
- "Rakefile",
23
- "VERSION",
24
- "lib/tach.rb",
25
- "tach.gemspec",
26
- "tests/tach_tests.rb",
27
- "tests/tests_helper.rb"
20
+ ".gitignore",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "lib/tach.rb",
25
+ "tach.gemspec",
26
+ "tests/tach_tests.rb",
27
+ "tests/tests_helper.rb"
28
28
  ]
29
29
  s.homepage = %q{http://github.com/geemus/tach}
30
30
  s.rdoc_options = ["--charset=UTF-8"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-09 00:00:00 -07:00
17
+ date: 2010-11-13 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency