[Haskell-cafe] Simple benchmark of list operations?

Bulat Ziganshin bulat.ziganshin at gmail.com
Sat Mar 10 08:56:03 EST 2007


Hello haskell-cafe,

Page http://community.livejournal.com/ru_lambda/44716.html
contains three very simple but long-working benchmark functions:

dummy :: [Int] -> [Int]
dummy   []   = []
dummy (x:xs) = x:dummy (dummy xs)

dummy2 :: [Int] -> [Int]
dummy2 = dum []
  where
    dum w   []   = w
    dum w (x:xs) = dum (w++[x]) (dummy2 xs)

dummy3 :: [Int] -> [Int]
dummy3 = dum []
  where
    dum w   []   = reverse w
    dum w (x:xs) = dum (x:w) (dummy3 xs)

*Main> dummy [1..21]
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]
(16.97 secs, 157120860 bytes)
*Main> dummy2 [1..21]
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]
(2.42 secs, 151470452 bytes)
*Main> dummy3 [1..21]
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]
(1.78 secs, 84642856 bytes)
*Main>

Is it interesting for testing haskell compilers?
  

-- 
Best regards,
 Bulat                          mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-Cafe mailing list