5.00.1 performance test

S.D.Mechveliani mechvel@math.botik.ru
Fri, 15 Jun 2001 13:00:12 +0400


Dear  ghc-5.00.1  (binary, linux, i386-unknown),

Here are some information on performance that may occur useful.

Choose  n,  run  test n  in various modes and compare the timings.
It consists mainly of merge sorting of a list of Int-s combined 
with reversing.
The particular points I find are

* ghc -interactive  runs the compiled with -O code  1.4 times slower
  than it is for the batch mode
  and needs considerably larger minimal heap to obtain the result.

* the performace difference between -O and -Onot looks small. 

-----------------
Serge Mechveliani
mechvel@botik.ru



-- statistics for  test 55000   -------------------------

ghc-5.00.1 -interpreted       time (under large heap)    = 13.3 sec,
                              minimal-needed(Heap -M...) = 12Mb

  compiled with -O -fvia-C -O2-for-C,
     loaded and run from  -interactive  time = 3.1,  min(Heap) = 9Mb
     linked and run in batch mode              2.2               5Mb

  -Onot, run from  -interactive                3.8              10Mb
 

ghc-4.04 -Onot    time for -M9m -H8m =  3.5 sec.
--------------------------------------------------------


module CompPlatf (test)
where
-- main = putStr $ shows (test 55000) "\n"

test :: Int -> Int
test n = max' $ sort' $ zipWith (-) (reverse xs) xs
                                                  where  xs = [1..n]
max' :: Ord a => [a] -> a
max' [x]      = x
max' (x:y:xs) = case  compare x y  of  LT -> max' (y:xs)
                                       _  -> max' (x:xs)
sort' :: Ord a => [a] -> [a]
sort'             xs  =  s $ mergePairs [[x] | x <- xs]
  where
  s []   = []
  s [xs] = xs
  s xss  = s $ mergePairs xss
  mergePairs (xs:ys:zss) = (merge xs ys):(mergePairs zss)
  mergePairs xss         = xss

merge :: Ord a => [a] -> [a] -> [a]
merge             []     ys     = ys
merge             xs     []     = xs
merge             (x:xs) (y:ys) = case  compare x y  of
                                           GT -> y:(merge (x:xs) ys)
                                           _  -> x:(merge xs (y:ys))