Skip to content

Instantly share code, notes, and snippets.

@supermomonga
Created July 8, 2013 12:52
Show Gist options
  • Save supermomonga/5948533 to your computer and use it in GitHub Desktop.
Save supermomonga/5948533 to your computer and use it in GitHub Desktop.
# coding: utf-8
include Java
class DataSet
def random scale
@random_array ||= scale.times.map { rand 1..scale }
@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 = 10000000
t1 = java.lang.System.nanoTime
ar = data.asc 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