Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'benchmark'
- # Average time using parallel approach 0.014400
- # Average time using implemented approach 0.000030
- PEG = "Peg".freeze
- CAR = "Car".freeze
- PEGCAR = "Pegcar".freeze
- def mapp
- (1..100).map do |current|
- if current % 5 == 0
- PEG
- elsif current % 7 == 0
- CAR
- elsif current % 35 == 0
- PEGCAR
- else
- current
- end
- end
- end
- Benchmark.bm do |b|
- b.report { mapp }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement