# [Haskell-cafe] Re: Simple benchmark of list operations?

Donald Bruce Stewart dons at cse.unsw.edu.au
Sat Mar 10 20:56:51 EST 2007

```bulat.ziganshin:
>
> 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?

Nice, I've added this to 'nobench':

http://www.cse.unsw.edu.au/~dons/code/nobench/imaginary/ru_list

You can see what the different compilers do to it here:

http://www.cse.unsw.edu.au/~dons/nobench/i686/results.html

-- Don
```