Use unpack1 instead of unpack(template) in erb.rb
unpack1(template) is faster than
Attached patch for
Use unpack1 instead of unpack and
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Updated by znz (Kazuhiro NISHIYAMA) almost 2 years ago
Using benchmark_driver gem,
unpack1(template) is about 1.07x faster than
% cat url_encode.yml prelude: | require 'erb' str = "Programming Ruby: The Pragmatic Programmer's Guide" benchmark: ERB::Util.url_encode(str) % benchmark_driver url_encode.yml -e ruby-base::$(rbenv root)/versions/git/bin/ruby -e ruby-unpack1::$(rbenv root)/versions/git2/bin/ruby benchmark results: Execution time (sec) name ruby-base ruby-unpack1 url_encode 1.793 1.665 Speedup ratio: compare with the result of `ruby-base' (greater is better) name ruby-unpack1 url_encode 1.077
Updated by k0kubun (Takashi Kokubun) almost 2 years ago
- Assignee changed from k0kubun (Takashi Kokubun) to znz (Kazuhiro NISHIYAMA)
Thank you for showing benchmark result.
While the impact is not so large with that benchmark, this would be expected usage of #unpack1 and it's good for maintainability too. So I think "not being slower in benchmark" is enough for adding this change.
I'm +1 for committing this.