Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

30 lines (24 sloc) 0.868 kb
module Main where
import Data.Time.Clock (diffUTCTime, getCurrentTime)
import System.Environment (getArgs)
import System.Random (StdGen, getStdGen, randoms)
import Sorting
-- testFunction = sort
-- testFunction = seqSort
-- testFunction = parSort
-- testFunction = sillySort
testFunction = parSort2 3
randomInts :: Int -> StdGen -> [Int]
randomInts k g = let result = take k (randoms g)
in force result `seq` result
main = do
args <- getArgs
let count | null args = 500000
| otherwise = read (head args)
input <- randomInts count `fmap` getStdGen
putStrLn $ "We have " ++ show (length input) ++ " elements to sort."
start <- getCurrentTime
let sorted = testFunction input
putStrLn $ "Sorted all " ++ show (length sorted) ++ " elements."
end <- getCurrentTime
putStrLn $ show (end `diffUTCTime` start) ++ " elapsed."
Jump to Line
Something went wrong with that request. Please try again.