say [+] $*IN.lines>>.Int

is quite faster.

On Mon, Sep 23, 2019 at 7:58 PM Marc Chantreux <e...@phear.org> wrote:

> hello,
>
> question: in raku, is there a faster solution than
>
>   say [+] lines
>
> long story;
>
> here is a thread i would like to reply to
>
>
> https://stackoverflow.com/questions/450799/shell-command-to-sum-integers-one-per-line
>
> because:
>
> * the perl5 answer is fast compared to the other dynamic langages
> * the shortest solution is very interesting: even if you have an average
>   level in dc (i think i have one), this is not that easy to read the
>   answer (commented in the post)
>
>     dc -f infile -e '[+z1<r]srz1<rp'
>
> obvioulsy: raku would be my prefered answer with:
>
>    seq 100000000 | perl6 -e 'say [+] lines'
>
> but ...
>
>    seq 100000000 | time perl6 -e 'say [+] lines'
>    5000000050000000
>    perl6 -e 'say [+] lines'  1591,80s user 3,04s system 122% cpu 21:36,63
> total
>
>    seq 100000000 | time /usr/bin/perl6 -e 'say [+] lines'
> 5000000050000000
> /usr/bin/perl6 -e 'say [+] lines'  2171,01s user 4,64s system 129% cpu
> 28:04,73 total
>
> when
>
>   perl6 -v
>     This is Rakudo version 2019.03.1 built on MoarVM version 2019.03
>     implementing Perl 6.d.
>   /usr/bin/perl6 -v
>     This is Rakudo version 2018.12 built on MoarVM version 2018.12
>     implementing Perl 6.d.
>
> regards
> marc
>

Reply via email to