bench_press 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bench_press}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
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-07-31}
12
+ s.date = %q{2010-08-01}
13
13
  s.default_executable = %q{bench_press}
14
14
  s.description = %q{Sharable benchmarks}
15
15
  s.email = %q{sandro.turriate@gmail.com}
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
35
35
  "examples/hash_merge.rb",
36
36
  "examples/implicit_versus_explicit_return.rb",
37
37
  "examples/regexp_matching.rb",
38
+ "examples/string_generation.rb",
38
39
  "lib/bench_press.rb",
39
40
  "lib/bench_press/cli.rb",
40
41
  "lib/bench_press/report.rb",
@@ -71,7 +72,8 @@ Gem::Specification.new do |s|
71
72
  "examples/existence_of_method.rb",
72
73
  "examples/hash_merge.rb",
73
74
  "examples/implicit_versus_explicit_return.rb",
74
- "examples/regexp_matching.rb"
75
+ "examples/regexp_matching.rb",
76
+ "examples/string_generation.rb"
75
77
  ]
76
78
 
77
79
  if s.respond_to? :specification_version then
@@ -0,0 +1,31 @@
1
+ require 'rubygems'
2
+ require 'bench_press'
3
+
4
+ extend BenchPress
5
+
6
+ author 'Sandro Turriate'
7
+ date '2010-07-31'
8
+ summary "String literals, interpolation, concatenation and array joins, all the many ways we create strings."
9
+
10
+
11
+ names = (first, middle, last = "First", "Middle", "Last")
12
+
13
+ measure "literal" do
14
+ "First Middle Last"
15
+ end
16
+
17
+ measure "interpolation" do
18
+ "#{first} #{middle} #{last}"
19
+ end
20
+
21
+ measure "append" do
22
+ "" << first << " " << middle << " " << last
23
+ end
24
+
25
+ measure "concatenation" do
26
+ first + " " + middle + " " + last
27
+ end
28
+
29
+ measure "array join" do
30
+ names.join " "
31
+ end
@@ -9,7 +9,7 @@ require 'bench_press/report'
9
9
  require 'bench_press/system_information'
10
10
 
11
11
  module BenchPress
12
- VERSION = '0.2.0'
12
+ VERSION = '0.2.1'
13
13
 
14
14
  autoload :RubyBenchmark, 'bench_press/ruby_benchmark'
15
15
 
@@ -67,7 +67,7 @@ module BenchPress
67
67
 
68
68
  def measurable
69
69
  @measurable ||= begin
70
- $0 = file_path
70
+ $0 = File.basename(file_path)
71
71
  load file_path
72
72
  BenchPress.run_at_exit = false
73
73
  BenchPress.current
@@ -82,7 +82,8 @@ module BenchPress
82
82
  def publish
83
83
  if email && email.any?
84
84
  measurable.email email
85
- RubyBenchmark.publish(measurable, file_path)
85
+ puts measurable.report; puts
86
+ puts RubyBenchmark.publish(measurable, file_path)
86
87
  else
87
88
  abort "Email missing. Use bench_press --publish --email me@example.com file.rb"
88
89
  end
@@ -39,6 +39,7 @@ module BenchPress
39
39
  :memory => SystemInformation.memory,
40
40
  :ruby_version => SystemInformation.ruby_version,
41
41
  :report => to_s,
42
+ :crypted_identifier => SystemInformation.crypted_identifier,
42
43
  :runnables => runnables.map {|r| r.to_hash}
43
44
  }
44
45
  end
@@ -18,14 +18,8 @@ module BenchPress
18
18
  @response = response
19
19
  end
20
20
 
21
- def report_url
22
- response.body if successful?
23
- end
24
-
25
- protected
26
-
27
- def successful?
28
- Net::HTTPSuccess === response.response
21
+ def to_s
22
+ response.body
29
23
  end
30
24
  end
31
25
  end
@@ -19,7 +19,7 @@ module BenchPress
19
19
  end
20
20
 
21
21
  def announce_ruby_version
22
- announce "Ruby version:", ruby_version
22
+ ruby_version
23
23
  end
24
24
 
25
25
  def cpu
@@ -47,7 +47,7 @@ module BenchPress
47
47
  end
48
48
 
49
49
  def ruby_version
50
- "#{RUBY_VERSION} patchlevel #{RUBY_PATCHLEVEL}"
50
+ RUBY_DESCRIPTION
51
51
  end
52
52
 
53
53
  def summary
@@ -7,7 +7,7 @@ describe BenchPress::RubyBenchmark do
7
7
  BenchPress::RubyBenchmark.base_uri "http://localhost:3000"
8
8
  end
9
9
 
10
- describe "#report_url" do
10
+ describe "#to_s" do
11
11
  subject do
12
12
  BenchPress::RubyBenchmark.publish measurable, measurable.path
13
13
  end
@@ -19,7 +19,7 @@ describe BenchPress::RubyBenchmark do
19
19
  end
20
20
 
21
21
  it "returns the response body" do
22
- subject.report_url.should =~ %r(http://localhost:3000/reports/\d+)
22
+ subject.to_s.should =~ %r(http://localhost:3000/reports/\d+)
23
23
  end
24
24
  end
25
25
 
@@ -29,12 +29,8 @@ describe BenchPress::RubyBenchmark do
29
29
  measurable.report.stub(:to_hash => invalid_hash)
30
30
  end
31
31
 
32
- it "has nil report url" do
33
- subject.report_url.should be_nil
34
- end
35
-
36
32
  it "contains error messages" do
37
- subject.response.body.should include("can't be blank")
33
+ subject.to_s.should include("can't be blank")
38
34
  end
39
35
  end
40
36
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe BenchPress::SystemInformation do
4
4
  before do
5
- BenchPress::SystemInformation.stub(:ruby_version => "1.8.7 patchlevel 174")
5
+ BenchPress::SystemInformation.stub(:ruby_version => "ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin10.2.0], MBARI 0x6770, Ruby Enterprise Edition 2010.01")
6
6
  end
7
7
 
8
8
  context "for Mac OS X" do
@@ -25,7 +25,7 @@ Operating System: Mac OS X 10.6.2 (10C540)
25
25
  CPU: Intel Core 2 Duo 2.4 GHz
26
26
  Processor Count: 2
27
27
  Memory: 4 GB
28
- Ruby version: 1.8.7 patchlevel 174
28
+ ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin10.2.0], MBARI 0x6770, Ruby Enterprise Edition 2010.01
29
29
  EOS
30
30
  BenchPress::SystemInformation.summary.should == summary.strip
31
31
  end
@@ -54,7 +54,7 @@ Operating System: Ubuntu 8.10
54
54
  CPU: Dual Core AMD Opteron(tm) Processor 270
55
55
  Processor Count: 4
56
56
  Memory: 254.75 MB
57
- Ruby version: 1.8.7 patchlevel 174
57
+ ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin10.2.0], MBARI 0x6770, Ruby Enterprise Edition 2010.01
58
58
  EOS
59
59
  BenchPress::SystemInformation.summary.should == summary.strip
60
60
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bench_press
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sandro Turriate
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-31 00:00:00 -04:00
18
+ date: 2010-08-01 00:00:00 -04:00
19
19
  default_executable: bench_press
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -124,6 +124,7 @@ files:
124
124
  - examples/hash_merge.rb
125
125
  - examples/implicit_versus_explicit_return.rb
126
126
  - examples/regexp_matching.rb
127
+ - examples/string_generation.rb
127
128
  - lib/bench_press.rb
128
129
  - lib/bench_press/cli.rb
129
130
  - lib/bench_press/report.rb
@@ -191,3 +192,4 @@ test_files:
191
192
  - examples/hash_merge.rb
192
193
  - examples/implicit_versus_explicit_return.rb
193
194
  - examples/regexp_matching.rb
195
+ - examples/string_generation.rb