Created
July 8, 2013 12:52
-
-
Save supermomonga/5948533 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 | |
@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