tach 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.rdoc +2 -2
  2. data/VERSION +1 -1
  3. data/lib/tach.rb +41 -21
  4. data/tach.gemspec +51 -0
  5. metadata +4 -3
data/README.rdoc CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Shotgun benchmarking with noticeable progress and pretty results.
4
4
 
5
- == Writing Benchmarks
5
+ WARNING: this is still really rough and results may not be the best yet, working on it.
6
6
 
7
- == Note on Patches/Pull Requests
7
+ == Writing Benchmarks
8
8
 
9
9
  Benchmarks are pretty easy, I'll explain a simple example
10
10
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
data/lib/tach.rb CHANGED
@@ -41,27 +41,19 @@ module Tach
41
41
  private
42
42
 
43
43
  def run_in_thread(name, count, &benchmark)
44
- if count.to_s.length > 3
45
- divisor = 1
46
- (count.to_s.length - 3).times do
47
- divisor *= 10
48
- end
49
- end
50
- thread = Thread.new {
51
- Thread.current[:results] ||= []
52
- Thread.current[:started_at] = Time.now
53
- Formatador.redisplay_progressbar(0, count, :label => name, :started_at => Thread.current[:started_at])
44
+ Formatador.display_line(name)
45
+ thread = Thread.new do
46
+ Thread.current[:results] = []
47
+ tach_start = Time.now
54
48
  for index in 1..count
55
- tach_start = Time.now
56
49
  instance_eval(&benchmark)
57
- Thread.current[:results] << Time.now.to_f - tach_start.to_f
58
- if !divisor || index % divisor == 0
59
- Formatador.redisplay_progressbar(index, count, :label => name, :started_at => Thread.current[:started_at])
60
- end
61
50
  end
62
- Formatador.display_line
63
- }
51
+ GC::start
52
+ tach_finish = Time.now
53
+ Thread.current[:results] << tach_finish.to_f - tach_start.to_f
54
+ end
64
55
  thread.join
56
+ Formatador.display_line
65
57
  thread[:results]
66
58
  end
67
59
 
@@ -72,17 +64,45 @@ end
72
64
  if __FILE__ == $0
73
65
 
74
66
  data = 'Content-Length: 100'
75
- Tach.meter(1_000_000) do
67
+ Tach.meter(100_000) do
68
+
69
+ tach('regex 1') do
70
+ header = data.match(/(.*):\s(.*)/)
71
+ [$1, $2]
72
+ end
76
73
 
77
- tach('regex') do
74
+ tach('regex 2') do
78
75
  header = data.match(/(.*):\s(.*)/)
79
76
  [$1, $2]
80
77
  end
81
78
 
82
- tach('split') do
83
- header = data.split(': ')
79
+ tach('regex 3') do
80
+ header = data.match(/(.*):\s(.*)/)
81
+ [$1, $2]
84
82
  end
85
83
 
86
84
  end
87
85
 
86
+ require 'benchmark'
87
+ Benchmark.bm do |bench|
88
+ bench.report('regex 1') do
89
+ 100_000.times do
90
+ header = data.match(/(.*):\s(.*)/)
91
+ [$1, $2]
92
+ end
93
+ end
94
+ bench.report('regex 2') do
95
+ 100_000.times do
96
+ header = data.match(/(.*):\s(.*)/)
97
+ [$1, $2]
98
+ end
99
+ end
100
+ bench.report('regex 3') do
101
+ 100_000.times do
102
+ header = data.match(/(.*):\s(.*)/)
103
+ [$1, $2]
104
+ end
105
+ end
106
+ end
107
+
88
108
  end
data/tach.gemspec ADDED
@@ -0,0 +1,51 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{tach}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["geemus (Wesley Beary)"]
12
+ s.date = %q{2010-04-09}
13
+ s.description = %q{Shotgun benchmarking with noticeable progress and pretty results.}
14
+ s.email = %q{wbeary@engineyard.com}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
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"
28
+ ]
29
+ s.homepage = %q{http://github.com/geemus/tach}
30
+ s.rdoc_options = ["--charset=UTF-8"]
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = %q{1.3.6}
33
+ s.summary = %q{Shotgun benchmarking}
34
+
35
+ if s.respond_to? :specification_version then
36
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
37
+ s.specification_version = 3
38
+
39
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
40
+ s.add_runtime_dependency(%q<formatador>, [">= 0.0.12"])
41
+ s.add_development_dependency(%q<shindo>, [">= 0"])
42
+ else
43
+ s.add_dependency(%q<formatador>, [">= 0.0.12"])
44
+ s.add_dependency(%q<shindo>, [">= 0"])
45
+ end
46
+ else
47
+ s.add_dependency(%q<formatador>, [">= 0.0.12"])
48
+ s.add_dependency(%q<shindo>, [">= 0"])
49
+ end
50
+ end
51
+
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 0
9
- version: 0.0.0
8
+ - 1
9
+ version: 0.0.1
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-07 00:00:00 -07:00
17
+ date: 2010-04-09 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -58,6 +58,7 @@ files:
58
58
  - Rakefile
59
59
  - VERSION
60
60
  - lib/tach.rb
61
+ - tach.gemspec
61
62
  - tests/tach_tests.rb
62
63
  - tests/tests_helper.rb
63
64
  has_rdoc: true