Guest User

Untitled

a guest
Feb 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. require 'benchmark'
  2. $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib' )))
  3. require 'randomaze'
  4.  
  5.  
  6. COUNT = 1000
  7.  
  8. template_str = 'abc[a-z]{3}foobar[0-9あいう]{5}__hoge'
  9. parse_result = Randomaze::String::TemplateParser.parse(template_str)
  10.  
  11. Benchmark.bm do |x|
  12. x.report 'from_array' do
  13. COUNT.times do
  14. Randomaze::String.from_template(parse_result)
  15. end
  16. end
  17. x.report 'with format' do
  18. COUNT.times do
  19. Randomaze::String.format(template_str)
  20. end
  21. end
  22. end
  23.  
  24. # On my environment( MacBook1.1 Intel Core Duo 1.83 GHz, 2GB), result is like that.
  25. #
  26. # ----------------------------------------------------------
  27. # result after 92ed088b6 ( before 0.0.4 )
  28. # user system total real
  29. # from_array 0.150000 0.000000 0.150000 ( 0.170900)
  30. # with format 0.370000 0.010000 0.380000 ( 0.421892)
Add Comment
Please, Sign In to add comment