benchmark_driver 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a09ccdd10d22d70ca190e43c4cdfa7bb6606f429
4
- data.tar.gz: 6346d84cc347aa2111842e1b07c36138683c9d5b
3
+ metadata.gz: 027b33623e6d71484da812d92ef6d4acbf154312
4
+ data.tar.gz: cb8da42411f02760787b766fa0d8a8622750ecd4
5
5
  SHA512:
6
- metadata.gz: eb5e63d89f0c344189467bde51efdd89a9a0e473eba30c15395d2c7f0e533f170ce164586b8c03a8e96f4cf89f5c804f0ff2f589e92b642e1b129ec00baccb8c
7
- data.tar.gz: 87b3a29d42c3b6628e572741902739e7f104a0f00a21e0a24e44dc22edacc623f14dd2524db90083a398a7bb8540fbc9cb9b2ee0c6250c3708290a89a1e49298
6
+ metadata.gz: a666e41732c84ab63b0b93460b77b01e2b1540b00199f4c71971b7da532f0531bd6daf9813c87a91f55be51fc37fd2ca12723062b294017986d9f98261df4475
7
+ data.tar.gz: ea81b5f7b48a02c99f5718ec4dff48e25dc07eede56d1194172ca209057a4d170405082907d2f3937a91779ee11a08e1dc443afbc29a355782d540923382c5a0
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # BenchmarkDriver
1
+ # BenchmarkDriver [![Build Status](https://travis-ci.org/k0kubun/benchmark_driver.svg?branch=master)](https://travis-ci.org/k0kubun/benchmark_driver)
2
2
 
3
3
  Benchmark driver for different Ruby executables
4
4
 
@@ -9,155 +9,158 @@ Benchmark driver for different Ruby executables
9
9
  ## Usage
10
10
 
11
11
  ```
12
- $ benchmark_driver -h
12
+ $ exe/benchmark_driver -h
13
13
  Usage: benchmark_driver [options] [YAML]
14
- -d, --duration [SECONDS] Duration seconds to run each benchmark (default: 1)
15
14
  -e, --executables [EXECS] Ruby executables (e1::path1; e2::path2; e3::path3;...)
16
- -r, --result-format=FORMAT Result output format [time|ips] (default: time)
15
+ -i, --ips [SECONDS] Measure IPS in duration seconds (default: 1)
16
+ -l, --loop-count [COUNT] Measure execution time with loop count (default: 100000)
17
17
  -v, --verbose
18
18
  ```
19
19
 
20
20
  ### Running single script
21
21
 
22
- With following `bm_app_erb.yml`,
22
+ With following `example_single.yml`,
23
23
 
24
24
  ```yml
25
25
  prelude: |
26
26
  require 'erb'
27
-
28
- title = "hello world!"
29
- content = "hello world!\n" * 10
30
-
31
- data = <<EOS
32
- <html>
33
- <head> <%= title %> </head>
34
- <body>
35
- <h1> <%= title %> </h1>
36
- <p>
37
- <%= content %>
38
- </p>
39
- </body>
40
- </html>
41
- EOS
42
-
43
- benchmark: |
44
- ERB.new(data).result(binding)
27
+ erb = ERB.new(%q[Hello <%= 'World' %>])
28
+ benchmark: erb.result
45
29
  ```
46
30
 
47
31
  you can benchmark the script with multiple ruby executables.
48
32
 
49
33
  ```
50
- $ benchmark_driver bm_app_erb.yml -e ruby1::ruby -e ruby2::ruby
34
+ $ exe/benchmark_driver ruby_benchmark_set/example_single.yml -e ruby1::ruby -e ruby2::ruby
51
35
  benchmark results:
52
36
  Execution time (sec)
53
37
  name ruby1 ruby2
54
- bm_app_erb 1.028 1.010
38
+ example_single 0.958 0.972
55
39
 
56
40
  Speedup ratio: compare with the result of `ruby1' (greater is better)
57
41
  name ruby2
58
- bm_app_erb 1.018
42
+ example_single 0.986
59
43
  ```
60
44
 
61
- And you can change benchmark output by `-r` option.
45
+ And you can change benchmark output to IPS (iteration per second) by `-i` option.
62
46
 
63
47
  ```
64
- $ benchmark_driver bm_app_erb.yml -e ruby1::ruby -e ruby2::ruby -r ips
48
+ $ exe/benchmark_driver ruby_benchmark_set/example_single.yml -e ruby1::ruby -e ruby2::ruby -i
65
49
  Result -------------------------------------------
66
50
  ruby1 ruby2
67
- bm_app_erb 16082.8 i/s 15541.7 i/s
51
+ example_single 99414.1 i/s 99723.3 i/s
68
52
 
69
- Comparison: bm_app_erb
70
- ruby1: 16082.8 i/s
71
- ruby2: 15541.7 i/s - 1.03x slower
53
+ Comparison: example_single
54
+ ruby2: 99723.3 i/s
55
+ ruby1: 99414.1 i/s - 1.00x slower
72
56
  ```
73
57
 
74
58
  ### Running multiple scripts
75
59
 
76
60
  One YAML file can contain multiple benchmark scripts.
77
- With following `erb_compile_render.yml`,
61
+ With following `example_multi.yml`,
78
62
 
79
63
  ```yml
80
- - name: erb_compile
81
- prelude: |
82
- require 'erb'
83
-
84
- title = "hello world!"
85
- content = "hello world!\n" * 10
86
-
87
- data = <<EOS
88
- <html>
89
- <head> <%= title %> </head>
90
- <body>
91
- <h1> <%= title %> </h1>
92
- <p>
93
- <%= content %>
94
- </p>
95
- </body>
96
- </html>
97
- EOS
98
-
99
- benchmark: |
100
- ERB.new(data).src
101
-
102
- - name: erb_render
103
- prelude: |
104
- require 'erb'
105
-
106
- title = "hello world!"
107
- content = "hello world!\n" * 10
108
-
109
- data = <<EOS
110
- <html>
111
- <head> <%= title %> </head>
112
- <body>
113
- <h1> <%= title %> </h1>
114
- <p>
115
- <%= content %>
116
- </p>
117
- </body>
118
- </html>
119
- EOS
120
-
121
- src = "def self.render(title, content); #{ERB.new(data).src}; end"
122
- mod = Module.new
123
- mod.instance_eval(src, "(ERB)")
124
-
125
- benchmark: |
126
- mod.render(title, content)
64
+ prelude: |
65
+ a = 'a' * 100
66
+ b = 'b' * 100
67
+ benchmarks:
68
+ - name: join
69
+ benchmark: |
70
+ [a, b].join
71
+ - name: interpolation
72
+ benchmark: |
73
+ "#{a}#{b}"
127
74
  ```
128
75
 
129
76
  you can benchmark the scripts with multiple ruby executables.
130
77
 
131
78
  ```
132
- $ benchmark_driver erb_compile_render.yml -e ruby1::ruby -e ruby2::ruby
79
+ $ exe/benchmark_driver ruby_benchmark_set/example_multi.yml -e ruby1::ruby -e ruby2::ruby
133
80
  benchmark results:
134
81
  Execution time (sec)
135
82
  name ruby1 ruby2
136
- erb_compile 0.987 0.985
137
- erb_render 0.834 0.809
83
+ join 0.022 0.022
84
+ interpolation 0.026 0.026
138
85
 
139
86
  Speedup ratio: compare with the result of `ruby1' (greater is better)
140
87
  name ruby2
141
- erb_compile 1.002
142
- erb_render 1.031
88
+ join 1.045
89
+ interpolation 1.002
143
90
  ```
144
91
 
145
92
  ```
146
- $ benchmark_driver erb_compile_render.yml -e ruby1::ruby -e ruby2::ruby -r ips
93
+ $ exe/benchmark_driver ruby_benchmark_set/example_multi.yml -e ruby1::ruby -e ruby2::ruby -i
147
94
  Result -------------------------------------------
148
95
  ruby1 ruby2
149
- erb_compile 30374.0 i/s 30832.1 i/s
150
- erb_render 628403.5 i/s 624588.0 i/s
96
+ join 4701954.3 i/s 4639520.3 i/s
97
+ interpolation 4263170.0 i/s 4044083.0 i/s
151
98
 
152
- Comparison: erb_compile
153
- ruby2: 30832.1 i/s
154
- ruby1: 30374.0 i/s - 1.02x slower
99
+ Comparison: join
100
+ ruby1: 4701954.3 i/s
101
+ ruby2: 4639520.3 i/s - 1.01x slower
155
102
 
156
- Comparison: erb_render
157
- ruby1: 628403.5 i/s
158
- ruby2: 624588.0 i/s - 1.01x slower
103
+ Comparison: interpolation
104
+ ruby1: 4263170.0 i/s
105
+ ruby2: 4044083.0 i/s - 1.05x slower
159
106
  ```
160
107
 
108
+ ### Configuring modes
109
+
110
+ There are 2 modes:
111
+
112
+ - Loop count: Enabled by `-l`. Optionally you can change count to loop by `-l COUNT`.
113
+ - IPS: Enabled by `-i`. Optionally you can change duration by `-i DURATION`.
114
+
115
+ Specifying both `-l` and `-i` is nonsense.
116
+
117
+ ### YAML syntax
118
+ You can specify `benchmark:` or `benchmarks:`.
119
+
120
+ #### Single
121
+ ```yml
122
+ name: String # optional (default: file name)
123
+ prelude: String # optional
124
+ loop_count: Integer # optional
125
+ benchmark: String # required
126
+ ```
127
+
128
+ #### Multi
129
+
130
+ ```yml
131
+ prelude: String # optional (shared)
132
+ loop_count: Integer # optional (shared)
133
+ benchmarks:
134
+ - name: String # required
135
+ prelude: String # optional (benchmark specific)
136
+ loop_count: Integer # optional (benchmark specific)
137
+ benchmark: String # required
138
+ ```
139
+
140
+ ### Debugging
141
+
142
+ If you have a trouble like an unexpectedly fast result, you should check benchmark script by `-v`.
143
+
144
+ ```
145
+ $ exe/benchmark_driver ruby_benchmark_set/example_multi.yml -v
146
+ --- Running "join" with "ruby" 957780 times ---
147
+ a = 'a' * 100
148
+ b = 'b' * 100
149
+
150
+
151
+ i = 0
152
+ while i < 957780
153
+ i += 1
154
+ [a, b].join
155
+
156
+ end
157
+ ```
158
+
159
+ ## TODO
160
+
161
+ - Measure multiple times and use minimum result
162
+ - Retry and reject negative result in ips mode
163
+ - Change not to take long time for iteration count estimation in ips mode
161
164
 
162
165
  ## Contributing
163
166
 
data/Rakefile CHANGED
@@ -1,6 +1,15 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
3
2
 
4
- RSpec::Core::RakeTask.new(:spec)
3
+ desc 'Run benchmarks in ruby_benchmark_set'
4
+ task :ruby_benchmark_set do
5
+ require 'bundler'
6
+ require 'shellwords'
5
7
 
6
- task :default => :spec
8
+ Dir.glob(File.expand_path('./ruby_benchmark_set/**/*.yml', __dir__)).sort.each do |path|
9
+ Bundler.with_clean_env do
10
+ sh [File.expand_path('./exe/benchmark_driver', __dir__), path].shelljoin
11
+ end
12
+ end
13
+ end
14
+
15
+ task default: :ruby_benchmark_set
@@ -24,5 +24,4 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_development_dependency 'bundler'
26
26
  spec.add_development_dependency 'rake'
27
- spec.add_development_dependency 'rspec'
28
27
  end
data/exe/benchmark_driver CHANGED
@@ -8,17 +8,19 @@ require 'yaml'
8
8
  options = {}
9
9
  args = OptionParser.new do |o|
10
10
  o.banner = "Usage: #{File.basename($0, '.*')} [options] [YAML]"
11
- o.on('-d', '--duration [SECONDS]', 'Duration seconds to run each benchmark (default: 1)') do |n|
12
- options[:duration] = n.to_i
13
- end
14
11
  o.on('-e', '--executables [EXECS]', 'Ruby executables (e1::path1; e2::path2; e3::path3;...)') do |e|
15
12
  options[:execs] ||= []
16
13
  e.split(/;/).each do |path|
17
14
  options[:execs] << path
18
15
  end
19
16
  end
20
- o.on('-r', "--result-format=FORMAT", "Result output format [time|ips] (default: time)", %w[time ips]) do |r|
21
- options[:result_format] = r
17
+ o.on('-i [DURATION]', '--ips [SECONDS]', "Measure IPS in duration seconds (default: #{BenchmarkDriver::DEFAULT_IPS_DURATION})") do |i|
18
+ options[:measure_type] = 'ips'
19
+ options[:measure_num] = i if i
20
+ end
21
+ o.on('-l [COUNT]', '--loop-count [COUNT]', "Measure execution time with loop count (default: #{BenchmarkDriver::DEFAULT_LOOP_COUNT})") do |l|
22
+ options[:measure_type] = 'loop_count'
23
+ options[:measure_num] = l if l
22
24
  end
23
25
  o.on('-v', '--verbose') do |v|
24
26
  options[:verbose] = v
@@ -28,9 +30,6 @@ abort "No YAML file is specified" if args.empty?
28
30
 
29
31
  driver = BenchmarkDriver.new(options)
30
32
  args.each do |yaml|
31
- benchmarks = YAML.load(File.read(yaml))
32
- if benchmarks.is_a?(Hash)
33
- benchmarks[:name] = File.basename(yaml, '.*')
34
- end
35
- driver.run(benchmarks)
33
+ default = { name: File.basename(yaml, '.*') }
34
+ driver.run(default.merge(YAML.load(File.read(yaml))))
36
35
  end
@@ -3,35 +3,39 @@ require 'benchmark'
3
3
  require 'tempfile'
4
4
 
5
5
  class BenchmarkDriver
6
- # @param [Integer] duration - Benchmark duration in seconds
6
+ MEASURE_TYPES = %w[loop_count ips]
7
+ DEFAULT_LOOP_COUNT = 100_000
8
+ DEFAULT_IPS_DURATION = 1
9
+
10
+ # @param [String] measure_type - "loop_count"|"ips"
11
+ # @param [Integer] measure_num - Loop count for "loop_type", duration seconds for "ips"
7
12
  # @param [Array<String>] execs - ["path1", "path2"] or `["ruby1::path1", "ruby2::path2"]`
8
- # @param [String] result_format
9
13
  # @param [Boolean] verbose
10
- def initialize(duration: 1, execs: ['ruby'], result_format: 'time', verbose: false)
11
- @duration = duration
14
+ def initialize(measure_type: 'loop_count', measure_num: nil, execs: ['ruby'], verbose: false)
15
+ unless MEASURE_TYPES.include?(measure_type)
16
+ abort "unsupported measure type: #{measure_type.dump}"
17
+ end
18
+ @measure_type = measure_type
19
+ @measure_num = measure_num
12
20
  @execs = execs.map do |exec|
13
21
  name, path = exec.split('::', 2)
14
22
  Executable.new(name, path || name)
15
23
  end
16
- @result_format = result_format
17
24
  @verbose = verbose
18
25
  end
19
26
 
20
- # @param [Hash,Array<Hash>] hashes
21
- def run(hashes)
22
- hashes = [hashes] if hashes.is_a?(Hash)
23
- benchmarks = hashes.map do |hash|
24
- BenchmarkScript.new(Hash[hash.map { |k, v| [k.to_sym, v] }])
25
- end
26
- if benchmarks.empty?
27
- abort 'No benchmark is specified in YAML'
28
- end
27
+ # @param [Hash] root_hash
28
+ def run(root_hash)
29
+ root = BenchmarkRoot.new(Hash[root_hash.map { |k, v| [k.to_sym, v] }])
29
30
 
30
- results = benchmarks.map do |benchmark|
31
+ results = root.benchmarks.map do |benchmark|
31
32
  metrics_by_exec = {}
32
33
  iterations = calc_iterations(@execs.first, benchmark)
33
34
  @execs.each do |exec|
34
- puts "Running #{benchmark.name.dump} with #{exec.name.dump} #{iterations} times..." if @verbose
35
+ if @verbose
36
+ puts "--- Running #{benchmark.name.dump} with #{exec.name.dump} #{iterations} times ---"
37
+ puts "#{benchmark.benchmark_script(iterations)}\n"
38
+ end
35
39
  elapsed_time = run_benchmark(exec, benchmark, iterations)
36
40
  metrics_by_exec[exec] = BenchmarkMetrics.new(iterations, elapsed_time)
37
41
  end
@@ -39,13 +43,13 @@ class BenchmarkDriver
39
43
  end
40
44
  puts if @verbose
41
45
 
42
- case @result_format
43
- when 'time'
44
- ExecutionTimeReporter.report(@execs, results)
46
+ case @measure_type
47
+ when 'loop_count'
48
+ LoopCountReporter.report(@execs, results)
45
49
  when 'ips'
46
50
  IpsReporter.report(@execs, results)
47
51
  else
48
- raise "unsupported result format: #{@result_format.dump}"
52
+ raise "unexpected measure type: #{@measure_type.dump}"
49
53
  end
50
54
  end
51
55
 
@@ -53,10 +57,18 @@ class BenchmarkDriver
53
57
 
54
58
  # Estimate iterations to finish benchmark within `@duration`.
55
59
  def calc_iterations(exec, benchmark)
56
- # TODO: Change to try from 1, 10, 100 ...
57
- base = 1000
58
- time = run_benchmark(exec, benchmark, base)
59
- (@duration / time * base).to_i
60
+ case @measure_type
61
+ when 'loop_count'
62
+ @measure_num || benchmark.loop_count || DEFAULT_LOOP_COUNT
63
+ when 'ips'
64
+ # TODO: Change to try from 1, 10, 100 ...
65
+ base = 1000
66
+ time = run_benchmark(exec, benchmark, base)
67
+ duration = @measure_num || DEFAULT_IPS_DURATION
68
+ (duration / time * base).to_i
69
+ else
70
+ raise "unexpected measure type: #{@measure_type.dump}"
71
+ end
60
72
  end
61
73
 
62
74
  def run_benchmark(exec, benchmark, iterations)
@@ -75,17 +87,55 @@ class BenchmarkDriver
75
87
  end
76
88
  end
77
89
 
90
+ class BenchmarkRoot
91
+ # @param [String] name
92
+ # @param [String] prelude
93
+ # @param [Integer,nil] loop_count
94
+ # @param [String,nil] benchmark - For running single instant benchmark
95
+ # @param [Array<Hash>] benchmarks - For running multiple benchmarks
96
+ def initialize(name:, prelude: '', loop_count: nil, benchmark: nil, benchmarks: [])
97
+ if benchmark
98
+ unless benchmarks.empty?
99
+ raise ArgumentError.new("Only either :benchmark or :benchmarks can be specified")
100
+ end
101
+ @benchmarks = [BenchmarkScript.new(name: name, prelude: prelude, benchmark: benchmark)]
102
+ else
103
+ @benchmarks = benchmarks.map do |hash|
104
+ BenchmarkScript.new(Hash[hash.map { |k, v| [k.to_sym, v] }]).tap do |b|
105
+ b.inherit_root(prelude: prelude, loop_count: loop_count)
106
+ end
107
+ end
108
+ end
109
+ end
110
+
111
+ # @return [Array<BenchmarkScript>]
112
+ attr_reader :benchmarks
113
+ end
114
+
78
115
  class BenchmarkScript
79
116
  # @param [String] name
80
117
  # @param [String] prelude
81
- # @param [String] script
82
- def initialize(name:, prelude: '', benchmark:)
118
+ # @param [String] benchmark
119
+ def initialize(name:, prelude: '', loop_count: nil, benchmark:)
83
120
  @name = name
84
121
  @prelude = prelude
122
+ @loop_count = loop_count
85
123
  @benchmark = benchmark
86
124
  end
125
+
126
+ # @return [String]
87
127
  attr_reader :name
88
128
 
129
+ # @return [Integer]
130
+ attr_reader :loop_count
131
+
132
+ def inherit_root(prelude:, loop_count:)
133
+ @prelude = "#{prelude}\n#{@prelude}"
134
+ if @loop_count.nil? && loop_count
135
+ @loop_count = loop_count
136
+ end
137
+ end
138
+
89
139
  def overhead_script(iterations)
90
140
  <<-RUBY
91
141
  #{@prelude}
@@ -137,7 +187,7 @@ end
137
187
  )
138
188
  end
139
189
 
140
- module ExecutionTimeReporter
190
+ module LoopCountReporter
141
191
  class << self
142
192
  # @param [Array<Executable>] execs
143
193
  # @param [Array<BenchmarkResult>] results
@@ -1,3 +1,3 @@
1
1
  class BenchmarkDriver
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -0,0 +1,4 @@
1
+ benchmarks:
2
+ - name: bm_vm2_array
3
+ benchmark: a = [1,2,3,4,5,6,7,8,9,10]
4
+ loop_count: 6000000
@@ -0,0 +1,10 @@
1
+ prelude: |
2
+ a = 'a' * 100
3
+ b = 'b' * 100
4
+ benchmarks:
5
+ - name: join
6
+ benchmark: |
7
+ [a, b].join
8
+ - name: interpolation
9
+ benchmark: |
10
+ "#{a}#{b}"
@@ -0,0 +1,4 @@
1
+ prelude: |
2
+ require 'erb'
3
+ erb = ERB.new(%q[Hello <%= 'World' %>])
4
+ benchmark: erb.result
@@ -0,0 +1,30 @@
1
+ prelude: |
2
+ require 'erb'
3
+
4
+ template = <<EOS
5
+ <html>
6
+ <head> <%= title %> </head>
7
+ <body>
8
+ <h1> <%= title %> </h1>
9
+ <p>
10
+ <%= content %>
11
+ </p>
12
+ </body>
13
+ </html>
14
+ EOS
15
+
16
+ title = "hello world!"
17
+ content = "hello world!\n" * 10
18
+
19
+ benchmarks:
20
+ - name: ERB compiling
21
+ benchmark: ERB.new(template)
22
+ loop_count: 10000
23
+
24
+ - name: ERB rendering
25
+ prelude: |
26
+ src = "def self.render(title, content); #{ERB.new(template).src}; end"
27
+ mod = Module.new
28
+ mod.instance_eval(src, "(ERB)")
29
+ benchmark: mod.render(title, content)
30
+ loop_count: 100000
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark_driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  description: Benchmark driver for different Ruby executables
56
42
  email:
57
43
  - takashikkbn@gmail.com
@@ -61,7 +47,6 @@ extensions: []
61
47
  extra_rdoc_files: []
62
48
  files:
63
49
  - ".gitignore"
64
- - ".rspec"
65
50
  - ".travis.yml"
66
51
  - Gemfile
67
52
  - LICENSE.txt
@@ -70,11 +55,13 @@ files:
70
55
  - benchmark_driver.gemspec
71
56
  - bin/console
72
57
  - bin/setup
73
- - examples/bm_app_erb.yml
74
- - examples/erb_compile_render.yml
75
58
  - exe/benchmark_driver
76
59
  - lib/benchmark_driver.rb
77
60
  - lib/benchmark_driver/version.rb
61
+ - ruby_benchmark_set/core/array.yml
62
+ - ruby_benchmark_set/example_multi.yml
63
+ - ruby_benchmark_set/example_single.yml
64
+ - ruby_benchmark_set/lib/erb.yml
78
65
  homepage: https://github.com/k0kubun/benchmark_driver
79
66
  licenses:
80
67
  - MIT
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
@@ -1,20 +0,0 @@
1
- prelude: |
2
- require 'erb'
3
-
4
- title = "hello world!"
5
- content = "hello world!\n" * 10
6
-
7
- data = <<EOS
8
- <html>
9
- <head> <%= title %> </head>
10
- <body>
11
- <h1> <%= title %> </h1>
12
- <p>
13
- <%= content %>
14
- </p>
15
- </body>
16
- </html>
17
- EOS
18
-
19
- benchmark: |
20
- ERB.new(data).result(binding)
@@ -1,47 +0,0 @@
1
- - name: erb_compile
2
- prelude: |
3
- require 'erb'
4
-
5
- title = "hello world!"
6
- content = "hello world!\n" * 10
7
-
8
- data = <<EOS
9
- <html>
10
- <head> <%= title %> </head>
11
- <body>
12
- <h1> <%= title %> </h1>
13
- <p>
14
- <%= content %>
15
- </p>
16
- </body>
17
- </html>
18
- EOS
19
-
20
- benchmark: |
21
- ERB.new(data).src
22
-
23
- - name: erb_render
24
- prelude: |
25
- require 'erb'
26
-
27
- title = "hello world!"
28
- content = "hello world!\n" * 10
29
-
30
- data = <<EOS
31
- <html>
32
- <head> <%= title %> </head>
33
- <body>
34
- <h1> <%= title %> </h1>
35
- <p>
36
- <%= content %>
37
- </p>
38
- </body>
39
- </html>
40
- EOS
41
-
42
- src = "def self.render(title, content); #{ERB.new(data).src}; end"
43
- mod = Module.new
44
- mod.instance_eval(src, "(ERB)")
45
-
46
- benchmark: |
47
- mod.render(title, content)