From 3efcb74036af32cbcc889d06d8c6c546289e89f4 Mon Sep 17 00:00:00 2001 From: k0kubun Date: Tue, 10 Jul 2018 15:58:52 +0000 Subject: [PATCH] benchmark: revise ERB benchmarks using YAML syntax to improve the accuracy of measurement by stop using block. benchmark/app_erb.rb -> benchmark/app_erb.yml: renamed and revised benchmark/erb_render.rb -> benchmark/erb_render.yml: ditto benchmark/README.md: follow renames git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- benchmark/README.md | 4 ++-- benchmark/app_erb.rb | 25 ------------------------- benchmark/app_erb.yml | 24 ++++++++++++++++++++++++ benchmark/erb_render.rb | 25 ------------------------- benchmark/erb_render.yml | 24 ++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 52 deletions(-) delete mode 100644 benchmark/app_erb.rb create mode 100644 benchmark/app_erb.yml delete mode 100644 benchmark/erb_render.rb create mode 100644 benchmark/erb_render.yml diff --git a/benchmark/README.md b/benchmark/README.md index a21cb4d324..4fc5134c0b 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -9,7 +9,7 @@ Execute `gem install benchmark_driver` and run a command like: ```bash # Run a benchmark script with the ruby in the $PATH -benchmark-driver benchmark/erb_render.rb +benchmark-driver benchmark/erb_fib.rb # Run all benchmark scripts with multiple Ruby executables or options benchmark-driver benchmark/*.yml -e /path/to/ruby -e '/path/to/ruby --jit' @@ -59,7 +59,7 @@ make benchmark ITEM=vm1 OPTS=--filter=block # You can specify the benchmark by an exact filename instead of using the default argument: # ARGS = $$(find $(srcdir)/benchmark -maxdepth 1 -name '*$(ITEM)*.yml' -o -name '*$(ITEM)*.rb') -make benchmark ARGS=../benchmark/erb_render.rb +make benchmark ARGS=../benchmark/erb_render.yml # You can specify any option via $OPTS make benchmark OPTS="--help" diff --git a/benchmark/app_erb.rb b/benchmark/app_erb.rb deleted file mode 100644 index 9a1cb2707f..0000000000 --- a/benchmark/app_erb.rb +++ /dev/null @@ -1,25 +0,0 @@ -# -# Create many HTML strings with ERB. -# - -require 'erb' - -data = < - <%= title %> - -

<%= title %>

-

- <%= content %> -

- - -erb - -max = 15_000 -title = "hello world!" -content = "hello world!\n" * 10 - -max.times{ - ERB.new(data).result(binding) -} diff --git a/benchmark/app_erb.yml b/benchmark/app_erb.yml new file mode 100644 index 0000000000..8583858d20 --- /dev/null +++ b/benchmark/app_erb.yml @@ -0,0 +1,24 @@ +# +# Create many HTML strings with ERB. +# +prelude: | + require 'erb' + + data = < + <%= title %> + +

<%= title %>

+

+ <%= content %> +

+ + + erb + + max = 15_000 + title = "hello world!" + content = "hello world!\n" * 10 +benchmark: + app_erb: ERB.new(data).result(binding) +loop_count: 15000 diff --git a/benchmark/erb_render.rb b/benchmark/erb_render.rb deleted file mode 100644 index 7dc0816c43..0000000000 --- a/benchmark/erb_render.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'erb' - -data = < - <%= title %> - -

<%= title %>

-

- <%= content %> -

- - -erb - -max = 1_500_000 -title = "hello world!" -content = "hello world!\n" * 10 - -src = "def self.render(title, content); #{ERB.new(data).src}; end" -mod = Module.new -mod.instance_eval(src, "(ERB)") - -max.times do - mod.render(title, content) -end diff --git a/benchmark/erb_render.yml b/benchmark/erb_render.yml new file mode 100644 index 0000000000..15f6c3880b --- /dev/null +++ b/benchmark/erb_render.yml @@ -0,0 +1,24 @@ +prelude: | + require 'erb' + + data = < + <%= title %> + +

<%= title %>

+

+ <%= content %> +

+ + + erb + + title = "hello world!" + content = "hello world!\n" * 10 + + src = "def self.render(title, content); #{ERB.new(data).src}; end" + mod = Module.new + mod.instance_eval(src, "(ERB)") +benchmark: + erb_render: mod.render(title, content) +loop_count: 1500000