diffbench 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +33 -8
- data/VERSION +1 -1
- data/bin/diffbench +5 -0
- data/diffbench.gemspec +4 -2
- data/lib/diffbench.rb +4 -1
- data/spec/bench.rb +12 -0
- data/spec/code.rb +8 -0
- data/spec/diffbench_spec.rb +43 -4
- metadata +19 -17
data/README.md
CHANGED
@@ -3,13 +3,12 @@
|
|
3
3
|
Diffbench is tool the I end up during many many performance patches to:
|
4
4
|
|
5
5
|
* Rails
|
6
|
-
* ActiveRecord
|
7
|
-
* ActiveModel
|
8
|
-
* ActiveSupport
|
9
|
-
* Mail
|
6
|
+
* ActiveRecord - [#5467](https://github.com/rails/rails/pull/5467)
|
7
|
+
* ActiveModel - [#5431](https://github.com/rails/rails/pull/5431)
|
8
|
+
* ActiveSupport - [#4493](https://github.com/rails/rails/pull/4493)
|
9
|
+
* Mail - [#396](https://github.com/mikel/mail/pull/369), [#366](https://github.com/mikel/mail/pull/366)
|
10
10
|
|
11
|
-
It runs a same benchmark code before and after applying a patch
|
12
|
-
TODO links to original PRs
|
11
|
+
It runs a same benchmark code before and after applying a patch.
|
13
12
|
|
14
13
|
## Installation
|
15
14
|
|
@@ -32,10 +31,14 @@ DiffBench.bm do
|
|
32
31
|
Mail::Header.new("X-Subscriber: 1111\n"* 1000)
|
33
32
|
end
|
34
33
|
report("headers parsing when tiny") do
|
35
|
-
|
34
|
+
10.times do
|
35
|
+
Mail::Header.new("X-Subscriber: 1111\n"* 10)
|
36
|
+
end
|
36
37
|
end
|
37
38
|
report("headers parsing when empty") do
|
38
|
-
|
39
|
+
100.times do
|
40
|
+
Mail::Header.new("")
|
41
|
+
end
|
39
42
|
end
|
40
43
|
end
|
41
44
|
```
|
@@ -50,4 +53,26 @@ If the working tree is dirty than diffbench will run benchmark against dirty and
|
|
50
53
|
If the working tree is not dirty than diffbench will run benchmark against current HEAD and commit previous to HEAD.
|
51
54
|
|
52
55
|
|
56
|
+
Output:
|
57
|
+
|
58
|
+
```
|
59
|
+
Running benchmark with current working tree
|
60
|
+
Checkout HEAD^
|
61
|
+
Running benchmark with HEAD^
|
62
|
+
Checkout to previous HEAD again
|
63
|
+
|
64
|
+
user system total real
|
65
|
+
----------------------------------headers parsing when long
|
66
|
+
After patch: 0.100000 0.000000 0.100000 ( 0.089926)
|
67
|
+
Before patch: 0.700000 0.000000 0.700000 ( 0.697444)
|
68
|
+
|
69
|
+
----------------------------------headers parsing when tiny
|
70
|
+
After patch: 0.000000 0.000000 0.000000 ( 0.009930)
|
71
|
+
Before patch: 0.020000 0.000000 0.020000 ( 0.024283)
|
72
|
+
|
73
|
+
---------------------------------headers parsing when empty
|
74
|
+
After patch: 0.010000 0.000000 0.010000 ( 0.002160)
|
75
|
+
Before patch: 0.000000 0.000000 0.000000 ( 0.002354)
|
76
|
+
```
|
77
|
+
|
53
78
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/bin/diffbench
CHANGED
data/diffbench.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "diffbench"
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bogdan Gusiev"]
|
12
|
-
s.date = "2012-03-
|
12
|
+
s.date = "2012-03-23"
|
13
13
|
s.description = "Diffbench is gem designed to benchmark the performance patches. It can run specified benchmark file before and after some changes made and show performance comparation result"
|
14
14
|
s.email = "agresso@gmail.com"
|
15
15
|
s.executables = ["diffbench"]
|
@@ -33,6 +33,8 @@ Gem::Specification.new do |s|
|
|
33
33
|
"features/support/env.rb",
|
34
34
|
"lib/diff_bench.rb",
|
35
35
|
"lib/diffbench.rb",
|
36
|
+
"spec/bench.rb",
|
37
|
+
"spec/code.rb",
|
36
38
|
"spec/diffbench_spec.rb",
|
37
39
|
"spec/spec_helper.rb"
|
38
40
|
]
|
data/lib/diffbench.rb
CHANGED
@@ -60,7 +60,10 @@ class DiffBench
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def run_file
|
63
|
-
output = `ruby #{@file}`
|
63
|
+
output = `ruby -I#{File.dirname(__FILE__)} #{@file}`
|
64
|
+
if $?.to_i > 0
|
65
|
+
raise Error, "Error exit code: #{$?.to_i}"
|
66
|
+
end
|
64
67
|
begin
|
65
68
|
result = YAML.load(output)
|
66
69
|
raise Error, "Can not parse result of ruby script: \n #{output}" unless result.is_a?(Hash)
|
data/spec/bench.rb
ADDED
data/spec/code.rb
ADDED
data/spec/diffbench_spec.rb
CHANGED
@@ -1,7 +1,46 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require "fileutils"
|
2
3
|
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
4
|
+
describe DiffBench do
|
5
|
+
let(:repo) do
|
6
|
+
"#{File.dirname(__FILE__)}/repo"
|
6
7
|
end
|
8
|
+
let!(:git) do
|
9
|
+
FileUtils.rm_rf(repo)
|
10
|
+
FileUtils.mkdir(repo)
|
11
|
+
git = Git.init(repo)
|
12
|
+
FileUtils.cp("spec/code.rb", repo)
|
13
|
+
git.add("code.rb")
|
14
|
+
git.commit("Init")
|
15
|
+
git
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
describe "when git tree is dirty" do
|
20
|
+
before do
|
21
|
+
content = File.read("#{repo}/code.rb")
|
22
|
+
File.open("#{repo}/code.rb", "w") do |f|
|
23
|
+
f.write(content.gsub(/TIME = 0\.2/, "TIME = 0.1"))
|
24
|
+
end
|
25
|
+
FileUtils.cp("spec/bench.rb", "#{repo}/bench.rb")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should run benchmark with dirty tree and clean tree" do
|
29
|
+
puts `cd #{repo}; ./../../bin/diffbench bench.rb`
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "when changes got commit" do
|
33
|
+
|
34
|
+
before(:each) do
|
35
|
+
git.add("code.rb")
|
36
|
+
git.commit("Commit")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should run benchmark with HEAD and HEAD^" do
|
40
|
+
puts `cd #{repo}; ./../../bin/diffbench bench.rb`
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
7
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diffbench
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: git
|
16
|
-
requirement: &
|
16
|
+
requirement: &15252040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *15252040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &15251480 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.8.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *15251480
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rdoc
|
38
|
-
requirement: &
|
38
|
+
requirement: &15250800 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3.12'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *15250800
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: cucumber
|
49
|
-
requirement: &
|
49
|
+
requirement: &15250180 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *15250180
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bundler
|
60
|
-
requirement: &
|
60
|
+
requirement: &15249420 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.1.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *15249420
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: jeweler
|
71
|
-
requirement: &
|
71
|
+
requirement: &15248740 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.8.3
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *15248740
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rcov
|
82
|
-
requirement: &
|
82
|
+
requirement: &15248240 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *15248240
|
91
91
|
description: Diffbench is gem designed to benchmark the performance patches. It can
|
92
92
|
run specified benchmark file before and after some changes made and show performance
|
93
93
|
comparation result
|
@@ -114,6 +114,8 @@ files:
|
|
114
114
|
- features/support/env.rb
|
115
115
|
- lib/diff_bench.rb
|
116
116
|
- lib/diffbench.rb
|
117
|
+
- spec/bench.rb
|
118
|
+
- spec/code.rb
|
117
119
|
- spec/diffbench_spec.rb
|
118
120
|
- spec/spec_helper.rb
|
119
121
|
homepage: http://github.com/bogdan/diffbench
|
@@ -131,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
133
|
version: '0'
|
132
134
|
segments:
|
133
135
|
- 0
|
134
|
-
hash:
|
136
|
+
hash: -1898630107307179820
|
135
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
138
|
none: false
|
137
139
|
requirements:
|