A sort program to show timing, needs to add timing routines.
#!/usr/local/bin/ruby
#!/usr/bin/ruby
# a sort program to show timing, needs to add timing routines
MAX = 20
x = Array.new
srand(13)
starttime = Time.now
for i in 0..MAX-1
x[i] = rand(1000)
puts "x[#{i}] = #{x[i]}"
end
for i in 0..MAX-2
for j in i+1..MAX-1
if x[i] > x[j]
t = x[i]
x[i] = x[j]
x[j] = t
end
end
end
puts("\nSorted numbers")
for i in 0..MAX-1
puts "x[#{i}] = #{x[i]}"
end
fintime = Time.now
elaptime = fintime - starttime
puts "Execution time = #{elaptime} seconds \n "