diffbench 0.1.0 → 0.1.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.1.0
1
+ 0.1.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "diffbench"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
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-23"
12
+ s.date = "2012-03-27"
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"]
@@ -1,6 +1,7 @@
1
1
  require "yaml"
2
2
  require "benchmark"
3
3
  require "git"
4
+ require "base64"
4
5
 
5
6
  class DiffBench
6
7
 
@@ -61,11 +62,18 @@ class DiffBench
61
62
 
62
63
  def run_file
63
64
  output = `ruby -I#{File.dirname(__FILE__)} #{@file}`
65
+ output.split("\n").select! do |line|
66
+ if line.start_with?("diffbench:")
67
+ true
68
+ else
69
+ puts line
70
+ end
71
+ end
64
72
  if $?.to_i > 0
65
73
  raise Error, "Error exit code: #{$?.to_i}"
66
74
  end
67
75
  begin
68
- result = YAML.load(output)
76
+ result = Encoder.decode(output)
69
77
  raise Error, "Can not parse result of ruby script: \n #{output}" unless result.is_a?(Hash)
70
78
  result
71
79
  rescue Psych::SyntaxError
@@ -95,7 +103,7 @@ class DiffBench
95
103
 
96
104
  def tree_dirty?
97
105
  status = git.status
98
- status.deleted.any? || status.changed.any? || status.added.any?
106
+ status.deleted.any? || status.changed.any?
99
107
  end
100
108
  end
101
109
 
@@ -119,15 +127,28 @@ class DiffBench
119
127
  instance_eval(&block)
120
128
  end
121
129
 
122
- puts @measures.to_yaml
130
+ print Encoder.encode(@measures)
123
131
  end
124
132
 
125
133
 
134
+
126
135
  def report(label)
127
136
  @measures[label] = Benchmark.measure do
128
137
  yield
129
138
  end
130
139
  end
131
140
  end
141
+
142
+ class Encoder
143
+ class << self
144
+ def encode(object)
145
+ "diffbench:#{Base64.encode64(object.to_yaml).gsub!("\n", "")}"
146
+ end
147
+
148
+ def decode(string)
149
+ YAML.load(Base64.decode64(string.split(":").last))
150
+ end
151
+ end
152
+ end
132
153
  class Error < StandardError; end
133
154
  end
@@ -3,6 +3,7 @@ class Sleeper
3
3
  TIME = 0.2
4
4
 
5
5
  def self.run
6
+ puts "--> Sleeping"
6
7
  sleep(TIME)
7
8
  end
8
9
  end
@@ -10,6 +10,7 @@ describe DiffBench do
10
10
  FileUtils.mkdir(repo)
11
11
  git = Git.init(repo)
12
12
  FileUtils.cp("spec/code.rb", repo)
13
+ FileUtils.cp("spec/bench.rb", "#{repo}/bench.rb")
13
14
  git.add("code.rb")
14
15
  git.commit("Init")
15
16
  git
@@ -22,7 +23,6 @@ describe DiffBench do
22
23
  File.open("#{repo}/code.rb", "w") do |f|
23
24
  f.write(content.gsub(/TIME = 0\.2/, "TIME = 0.1"))
24
25
  end
25
- FileUtils.cp("spec/bench.rb", "#{repo}/bench.rb")
26
26
  end
27
27
 
28
28
  it "should run benchmark with dirty tree and clean tree" do
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.1.0
4
+ version: 0.1.1
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-23 00:00:00.000000000 Z
12
+ date: 2012-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: git
16
- requirement: &15252040 !ruby/object:Gem::Requirement
16
+ requirement: &8469000 !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: *15252040
24
+ version_requirements: *8469000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &15251480 !ruby/object:Gem::Requirement
27
+ requirement: &8467980 !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: *15251480
35
+ version_requirements: *8467980
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdoc
38
- requirement: &15250800 !ruby/object:Gem::Requirement
38
+ requirement: &8466960 !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: *15250800
46
+ version_requirements: *8466960
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: cucumber
49
- requirement: &15250180 !ruby/object:Gem::Requirement
49
+ requirement: &8466160 !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: *15250180
57
+ version_requirements: *8466160
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &15249420 !ruby/object:Gem::Requirement
60
+ requirement: &8465060 !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: *15249420
68
+ version_requirements: *8465060
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &15248740 !ruby/object:Gem::Requirement
71
+ requirement: &8480380 !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: *15248740
79
+ version_requirements: *8480380
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rcov
82
- requirement: &15248240 !ruby/object:Gem::Requirement
82
+ requirement: &8479640 !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: *15248240
90
+ version_requirements: *8479640
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
@@ -133,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  segments:
135
135
  - 0
136
- hash: -1898630107307179820
136
+ hash: 1579437980307483478
137
137
  required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements: