Created
June 25, 2013 03:29
-
-
Save supermomonga/5855712 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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