Created
August 30, 2013 14:03
-
-
Save cronin101/6390188 to your computer and use it in GitHub Desktop.
Benchmark1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require './hadope' | |
| require 'benchmark' | |
| puts "Problem, mapping an addition (or two) to a large Array" | |
| Hadope::set_device Hadope::CPU | |
| input = (1..10_000_000).to_a | |
| ruby = Benchmark.realtime { | |
| last = input.map { |i| i + 1 }.map { |j| j + 1 }.last | |
| puts "Ruby says last result is #{last}" | |
| } | |
| opencl = Benchmark.realtime { | |
| last = input[Integers].map(i:'i + 1').map(j:'j + 1')[Fixnums].last | |
| puts "OpenCL says last result is #{last}" | |
| } | |
| puts "Ruby: #{ruby.inspect}, OpenCL: #{opencl.inspect}" | |
| =begin | |
| λ HaDope git:(master) ✗ ./Benchmark.rb | |
| Problem, mapping an addition (or two) to a large Array | |
| Ruby says last result is 10000002 | |
| OpenCL says last result is 10000002 | |
| Ruby: 1.503207, OpenCL: 0.270248 | |
| =end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment