Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. prelude: |
  2. hash = {a: 1}
  3. arr = [hash]
  4. arr2 = [1]
  5. class Object
  6. def a(x) end
  7. if ENV['R2']
  8. ruby2_keywords def foo(*args) bar(*args) end
  9. else
  10. def foo(*args, **kw) bar(*args, **kw) end
  11. end
  12. def bar(*args) end
  13. end
  14.  
  15. if ENV['R2']
  16. b = proc do
  17. 300.times{a(*arr)}
  18. foo(*arr)
  19. end
  20. else
  21. b = proc do
  22. 300.times{a(*arr)}
  23. foo(*arr, **{})
  24. end
  25. end
  26. c = proc do
  27. 300.times{a(*arr)}
  28. foo(*arr2)
  29. end
  30. benchmark:
  31. worst_case: "a(*arr)"
  32. one_per_3hundred_hash: "b.call"
  33. one_per_3hundred_nonhash: "c.call"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement