Re: Speeding up trivial programs

Viktor Dukhovni <[email protected]>
Newsgroups gmane.comp.lang.haskell.cafe
Message-ID <[email protected]>
On Fri, Aug 23, 2024 at 09:22:15PM +0100, Teofil Camarasu wrote:

> On my computer (and using GHC-9.8) it's a bit quicker:
> real    0m0.006s
> user    0m0.001s
> sys     0m0.005s
> 
> I imagine some of this time is just loading things into memory and/or
> running the dynamic linker.
> 
> If you are optimising for start up time, maybe fully statically linking
> your executable might help.

I see similarly low startup using GHC 9.8:

    $ cat hw.hs
    module Main(main) where

    main :: IO ()
    main = putStrLn "Hello World!"

    $ ghc --version
    The Glorious Glasgow Haskell Compilation System, version 9.8.2

    $ ghc -O2 hw.hs
    [1 of 2] Compiling Main             ( hw.hs, hw.o )
    [2 of 2] Linking hw

    $ time ./hw
    Hello World!

    real    0m0.005s
    user    0m0.001s
    sys     0m0.004s

The corresponding C program is not dramatically faster:

    $ cat hw.c
    #include <stdio.h>

    int main(void)
    {
        printf("Hello World!\n");
        return 0;
    }

    $ cc -o hw hw.c

    $ time ./hw
    Hello World!

    real    0m0.002s
    user    0m0.000s
    sys     0m0.002s

So 150ms is fairly anomalous, feels like a site or platform-specific issue,
rather than expected RTS overhead.

-- 
    Viktor.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.