summaryrefslogtreecommitdiff
path: root/benchmark/so_array.yml
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/so_array.yml')
-rw-r--r--benchmark/so_array.yml25
1 files changed, 25 insertions, 0 deletions
diff --git a/benchmark/so_array.yml b/benchmark/so_array.yml
new file mode 100644
index 0000000..e686438
--- /dev/null
+++ b/benchmark/so_array.yml
@@ -0,0 +1,25 @@
+prelude: |
+ #!/usr/bin/ruby
+ # -*- mode: ruby -*-
+ # $Id: ary-ruby.code,v 1.4 2004/11/13 07:41:27 bfulgham Exp $
+ # http://www.bagley.org/~doug/shootout/
+ # with help from Paul Brannan and Mark Hubbart
+benchmark:
+ so_array: |
+
+ n = 9000 # Integer(ARGV.shift || 1)
+
+ x = Array.new(n)
+ y = Array.new(n, 0)
+
+ n.times{|bi|
+ x[bi] = bi + 1
+ }
+
+ (0 .. 999).each do |e|
+ (n-1).step(0,-1) do |bi|
+ y[bi] += x.at(bi)
+ end
+ end
+ # puts "#{y.first} #{y.last}"
+loop_count: 1