[Haskell-cafe] Speeding up trivial programs

amindfv at mailbox.org amindfv at mailbox.org
Fri Aug 23 18:49:26 UTC 2024


I'm working on a small program that has to run many, many times, as quickly as possible (yes, it needs to be a standalone program).

I've optimized it in many ways, but I seem to have a time floor, observable with "Hello, world"


    $ cat Hello.hs
    main = putStrLn "Hello world"
    $ ghc -O2 Hello.hs
    $ time ./Hello
    Hello world
    
    real    0m0.150s
    user    0m0.117s
    sys     0m0.032s


The equivalent program in C takes only 0.002s (75x faster).

What is taking the extra time? Is it the RTS "booting"? Is there any way to speed this up?

Thanks,
Tom


More information about the Haskell-Cafe mailing list