Fix for JRUBY-2882. Handle error messages related to constructors better
[jruby.git] / bench / shootout / hash2.ruby
blobd167a74f97d94db15e57ce130e09113db363c116
1 #!/usr/bin/ruby
2 # -*- mode: ruby -*-
3 # $Id: hash2.ruby,v 1.2 2004-11-10 06:36:29 bfulgham Exp $
4 # http://shootout.alioth.debian.org/
5 # Revised by Dave Anderson
7 n = Integer(ARGV.shift || 1)
9 hash1 = {}
10 i = 0
11 for i in 0 .. 9999
12 hash1["foo_" << i.to_s] = i
13 end
15 hash2 = Hash.new(0)
16 n.times do
17 for i in hash1.keys
18 hash2[i] += hash1[i]
19 end
20 end
22 printf "%d %d %d %d\n",
23 hash1["foo_1"], hash1["foo_9999"], hash2["foo_1"], hash2["foo_9999"]