Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'benchmark'
- $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib' )))
- require 'randomaze'
- COUNT = 1000
- template_str = 'abc[a-z]{3}foobar[0-9あいう]{5}__hoge'
- parse_result = Randomaze::String::TemplateParser.parse(template_str)
- Benchmark.bm do |x|
- x.report 'from_array' do
- COUNT.times do
- Randomaze::String.from_template(parse_result)
- end
- end
- x.report 'with format' do
- COUNT.times do
- Randomaze::String.format(template_str)
- end
- end
- end
- # On my environment( MacBook1.1 Intel Core Duo 1.83 GHz, 2GB), result is like that.
- #
- # ----------------------------------------------------------
- # result after 92ed088b6 ( before 0.0.4 )
- # user system total real
- # from_array 0.150000 0.000000 0.150000 ( 0.170900)
- # with format 0.370000 0.010000 0.380000 ( 0.421892)
Add Comment
Please, Sign In to add comment