News for hackers. Stuff that matters.
Re:Imperative Haskell by lgas on Wednesday May 31, 2017 @02:53AM (#14450804)
I tried to do some quick benchmarks:

    % make hs
    Results: [25872791,24253954,21258158]
    make hs  6.53s user 3.99s system 245% cpu 4.282 total

    % make py
    24029582
    25343914
    20814678
    make py  22.37s user 0.11s system 99% cpu 22.593 total
You can see the code as tested here[0]. I am not an expert on either Haskell or Python performance, all I did was use -O for python3 and -O2 for GHC. This was on a 2.8 GHz Core i7 Macbook, FWIW.

Edit: Since 'contents' was unspecified I used one million random ints.

[0]: https://github.com/lgastako/compimp/tree/as-tested

Re:Imperative Haskell by lgas on Wednesday May 31, 2017 @03:03AM (#14450832)
I was playing around a little more and I noticed that stack sets the following ghc-options by default:

    -threaded -rtsopts -with-rtsopts=-N
which I assumed explained some of the speedup, so I disabled them and got a reduction to 99% cpu as expected, but unexpectedly the single threaded version was about twice as fast:

    % make hs
    Results: [24605537,25150983,21576960]
    make hs  3.13s user 0.07s system 99% cpu 3.211 total
Re:Imperative Haskell by sbergot on Wednesday May 31, 2017 @07:41AM (#14451699)
Haskell threaded runtime can have poorer performances than the non-threaded one on single threaded programs.
Re:Imperative Haskell by bojo on Wednesday May 31, 2017 @04:35AM (#14451100)
Depending on your problem you can actually lose performance with a multi-threaded app due to the context switching overhead.
Re:Imperative Haskell by Veedrac on Wednesday May 31, 2017 @06:48PM (#14456531)

    $ time make hs
    Results: [24639155,24977202,20874958]
    make hs  8.39s user 5.93s system 322% cpu 4.435 total

    $ time make py
    24894022
    25787638
    21979201
    make py  14.33s user 0.02s system 99% cpu 14.353 total

    $ time make py PYTHON=pypy3
    25059732
    25318854
    21254890
    make py PYTHON=pypy3  4.02s user 0.06s system 99% cpu 4.082 total
Re:Imperative Haskell by lgas on Thursday June 01, 2017 @03:36AM (#14458595)
Very nice.
Re:Imperative Haskell by etatoby on Wednesday May 31, 2017 @01:38PM (#14454395)
Oh come on, how can you expect similar execution time between a compiled language like Haskell and an interpreter like Python? I would be very surprised if the latter was not several times slower, purity or not.

If anything, you may want to compare compiled Haskell code to an impure, imperative language that is also strongly typed, compiled to machine language, and garbage collected, like Go.

Re:Imperative Haskell by lgas on Wednesday May 31, 2017 @01:54PM (#14454521)
I didn't expect similar execution time between them, not sure where you got that idea.
Re:Imperative Haskell by vaibhavsagar on Wednesday May 31, 2017 @04:11AM (#14451037)
I took `contents` from here[0] but I like your random ints much better!

[0]: https://github.com/vaibhavsagar/thursday-presentations/blob/...