Greetings.

Using GHC 6.0 on Mac OS X (10.2.6), I'm trying to do some timing
tests of something that doesn't take very long.  So, I want to call
a function repeatedly (1000s of times).  It appears, however, that
the compiler is figuring out that there's no need to call the
function more than once since it's pure.

Is there anything simple I can do to get the compiler to call a
function repeatedly?

Here is a snippet of code showing what I am trying right now:

    main = do
        t0 <- getClockTime
        times 1000
        t1 <- getClockTime
        . . .

    times :: Int -> IO ()
    times 0 = return ()
    times n = do
        let [a,b,c,d] = take 4 (myFunction)
        Control.Exception.evaluate a
        Control.Exception.evaluate b
        Control.Exception.evaluate c
        Control.Exception.evaluate d
        times $! n - 1

    myFunction :: [Int]
    myFunction = . . .

(There may be some absurd stuff in this code;  I've left in the
remnants of several failed attempts.)

Regards,

Jeff Scofield

_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to