bench_press 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ begin
12
12
  gem.authors = ["Sandro Turriate"]
13
13
  gem.add_dependency "facter", "1.5.7"
14
14
  gem.add_dependency "activesupport", "2.3.5"
15
- gem.add_development_dependency "rspec", "1.2.9"
15
+ gem.add_development_dependency "rspec", "1.3.0"
16
16
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
17
  end
18
18
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bench_press}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sandro Turriate"]
12
- s.date = %q{2010-01-20}
12
+ s.date = %q{2010-03-13}
13
13
  s.default_executable = %q{bench_press}
14
14
  s.description = %q{Sharable benchmarks}
15
15
  s.email = %q{sandro.turriate@gmail.com}
@@ -40,12 +40,13 @@ Gem::Specification.new do |s|
40
40
  "spec/bench_press/result_spec.rb",
41
41
  "spec/bench_press/system_information_spec.rb",
42
42
  "spec/bench_press_spec.rb",
43
+ "spec/spec.opts",
43
44
  "spec/spec_helper.rb"
44
45
  ]
45
46
  s.homepage = %q{http://github.com/sandro/bench_press}
46
47
  s.rdoc_options = ["--charset=UTF-8"]
47
48
  s.require_paths = ["lib"]
48
- s.rubygems_version = %q{1.3.5}
49
+ s.rubygems_version = %q{1.3.6}
49
50
  s.summary = %q{Sharable benchmarks}
50
51
  s.test_files = [
51
52
  "spec/bench_press/report_spec.rb",
@@ -53,6 +54,7 @@ Gem::Specification.new do |s|
53
54
  "spec/bench_press/system_information_spec.rb",
54
55
  "spec/bench_press_spec.rb",
55
56
  "spec/spec_helper.rb",
57
+ "examples/array_vs_string_concatenation.rb",
56
58
  "examples/compare_rr_to_rspec.rb",
57
59
  "examples/existence_of_method.rb",
58
60
  "examples/hash_merge.rb",
@@ -66,16 +68,16 @@ Gem::Specification.new do |s|
66
68
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
67
69
  s.add_runtime_dependency(%q<facter>, ["= 1.5.7"])
68
70
  s.add_runtime_dependency(%q<activesupport>, ["= 2.3.5"])
69
- s.add_development_dependency(%q<rspec>, ["= 1.2.9"])
71
+ s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
70
72
  else
71
73
  s.add_dependency(%q<facter>, ["= 1.5.7"])
72
74
  s.add_dependency(%q<activesupport>, ["= 2.3.5"])
73
- s.add_dependency(%q<rspec>, ["= 1.2.9"])
75
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
74
76
  end
75
77
  else
76
78
  s.add_dependency(%q<facter>, ["= 1.5.7"])
77
79
  s.add_dependency(%q<activesupport>, ["= 2.3.5"])
78
- s.add_dependency(%q<rspec>, ["= 1.2.9"])
80
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
79
81
  end
80
82
  end
81
83
 
@@ -0,0 +1,30 @@
1
+ $:.unshift(File.dirname(__FILE__) + "/../lib")
2
+ require 'bench_press'
3
+
4
+ extend BenchPress
5
+
6
+ reps 100_000
7
+ array = []
8
+ measure "Array#<<" do |repetition|
9
+ array << "1234567890"
10
+ end
11
+
12
+ string = ""
13
+ measure "String#<<" do |repetition|
14
+ string << "1234567890"
15
+ end
16
+
17
+ a = (1..1000).to_a
18
+ measure "Array#clear" do
19
+ a.dup.clear
20
+ end
21
+
22
+ measure "Array#replace" do
23
+ a.dup
24
+ a.replace []
25
+ end
26
+
27
+ measure "Re-assigning to new array" do
28
+ a.dup
29
+ a = []
30
+ end
@@ -1,4 +1,5 @@
1
1
  require 'active_support/inflector'
2
+ require 'date'
2
3
  require 'benchmark'
3
4
  require 'facter'
4
5
  require 'bench_press/runnable'
@@ -7,7 +8,7 @@ require 'bench_press/report'
7
8
  require 'bench_press/system_information'
8
9
 
9
10
  module BenchPress
10
- VERSION = '0.1.2'
11
+ VERSION = '0.1.3'
11
12
 
12
13
  def self.extended(base)
13
14
  base.instance_variable_set(:@module_name, base.name) if base.respond_to?(:name)
@@ -59,12 +60,16 @@ module BenchPress
59
60
  protected
60
61
 
61
62
  def default_report_name
62
- module_name || ActiveSupport::Inflector.titleize(File.basename($0, ".rb"))
63
+ module_name || ActiveSupport::Inflector.titleize(File.basename(calling_script, ".rb"))
63
64
  end
64
65
 
65
66
  def report_name
66
67
  name || default_report_name
67
68
  end
69
+
70
+ def calling_script
71
+ $0
72
+ end
68
73
  end
69
74
 
70
75
  at_exit do
@@ -113,29 +113,3 @@ module BenchPress
113
113
  end
114
114
  end
115
115
  end
116
-
117
- __END__
118
-
119
- HASH MERGE
120
- ===========
121
- Author: Sandro Turriate
122
- Date: 12-12-09
123
- Summary: Fastest way to merge or append a hash to another hash
124
-
125
- System Information
126
- ------------------
127
- Operating System: Mac OS X 10.6.2 (10C540)
128
- CPU: Intel Core 2 Duo 2.4 GHz
129
- Processor Count: 2
130
- Memory: 4 GB
131
- Ruby version: 1.8.7 patchlevel 174
132
-
133
-
134
- "Implicit return" is up to 17% faster over 1000 repetitions
135
- -----------------------------------------------------
136
- Implicit Return 0.00029 secs Fastest
137
- Explicit 0.00035 secs 17% Slower
138
-
139
- 50% faster is 25 secs rather than 50, 50x = (50-25)
140
- 35x = (35-29) = 17%
141
- .00035x = .00006
@@ -20,7 +20,9 @@ module BenchPress
20
20
 
21
21
  def run
22
22
  @run_time = Benchmark.realtime do
23
- self.class.repetitions.times &code_block
23
+ self.class.repetitions.times do |i|
24
+ code_block.call(i)
25
+ end
24
26
  end
25
27
  end
26
28
  end
@@ -23,6 +23,7 @@ describe BenchPress do
23
23
  end
24
24
  extend BenchPress
25
25
  end
26
+ mod.stub(:calling_script => "bench_press.rb")
26
27
  mod.send(:default_report_name).should == "Bench Press"
27
28
  end
28
29
  end
@@ -0,0 +1,2 @@
1
+ --color
2
+ --backtrace
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bench_press
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 3
9
+ version: 0.1.3
5
10
  platform: ruby
6
11
  authors:
7
12
  - Sandro Turriate
@@ -9,39 +14,51 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-20 00:00:00 -05:00
17
+ date: 2010-03-13 00:00:00 -05:00
13
18
  default_executable: bench_press
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: facter
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - "="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 5
30
+ - 7
23
31
  version: 1.5.7
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: activesupport
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - "="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 3
44
+ - 5
33
45
  version: 2.3.5
34
- version:
46
+ type: :runtime
47
+ version_requirements: *id002
35
48
  - !ruby/object:Gem::Dependency
36
49
  name: rspec
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
40
52
  requirements:
41
53
  - - "="
42
54
  - !ruby/object:Gem::Version
43
- version: 1.2.9
44
- version:
55
+ segments:
56
+ - 1
57
+ - 3
58
+ - 0
59
+ version: 1.3.0
60
+ type: :development
61
+ version_requirements: *id003
45
62
  description: Sharable benchmarks
46
63
  email: sandro.turriate@gmail.com
47
64
  executables:
@@ -73,6 +90,7 @@ files:
73
90
  - spec/bench_press/result_spec.rb
74
91
  - spec/bench_press/system_information_spec.rb
75
92
  - spec/bench_press_spec.rb
93
+ - spec/spec.opts
76
94
  - spec/spec_helper.rb
77
95
  - TODO
78
96
  has_rdoc: true
@@ -88,18 +106,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
106
  requirements:
89
107
  - - ">="
90
108
  - !ruby/object:Gem::Version
109
+ segments:
110
+ - 0
91
111
  version: "0"
92
- version:
93
112
  required_rubygems_version: !ruby/object:Gem::Requirement
94
113
  requirements:
95
114
  - - ">="
96
115
  - !ruby/object:Gem::Version
116
+ segments:
117
+ - 0
97
118
  version: "0"
98
- version:
99
119
  requirements: []
100
120
 
101
121
  rubyforge_project:
102
- rubygems_version: 1.3.5
122
+ rubygems_version: 1.3.6
103
123
  signing_key:
104
124
  specification_version: 3
105
125
  summary: Sharable benchmarks
@@ -109,6 +129,7 @@ test_files:
109
129
  - spec/bench_press/system_information_spec.rb
110
130
  - spec/bench_press_spec.rb
111
131
  - spec/spec_helper.rb
132
+ - examples/array_vs_string_concatenation.rb
112
133
  - examples/compare_rr_to_rspec.rb
113
134
  - examples/existence_of_method.rb
114
135
  - examples/hash_merge.rb