Skip to content

Instantly share code, notes, and snippets.

@supermomonga
Created June 25, 2013 03:29
Show Gist options
  • Save supermomonga/5855712 to your computer and use it in GitHub Desktop.
Save supermomonga/5855712 to your computer and use it in GitHub Desktop.
# coding: utf-8
include Java
class DataSet
def random scale
if !@random_array
@random_array = scale.times.map do
rand 1..scale
end
end
@random_array
end
def identical scale
[1] * scale
end
def asc scale
( 1..scale ).to_a
end
def desc scale
asc(scale).reverse
end
end
class SortPerformance
end
data = DataSet.new
scale = 6000000
t1 = java.lang.System.nanoTime
ar = data.random scale
t2 = java.lang.System.nanoTime
puts "#{ t2 - t1 } nano seconds for generating #{ scale } elements' array."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment