Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance vs Raku #17964

Closed
philiprbrenan opened this issue Jul 10, 2020 · 2 comments
Closed

Performance vs Raku #17964

philiprbrenan opened this issue Jul 10, 2020 · 2 comments

Comments

@philiprbrenan
Copy link

Please tell me why Perl is so much slower then Raku in this instance?

time raku test.raku >/dev/null

real    0m0.640s
user    0m0.674s
sys     0m0.028s

time perl -Mbigint test.raku >/dev/null

real    0m15.599s
user    0m15.597s
sys     0m0.000s

cat test.raku
my ($prev, $current) = (1, 0);

for (0..100_000) {
    ($prev, $current) = ($current, $prev + $current);
}
print $current;
@xenu
Copy link
Member

xenu commented Jul 11, 2020

It's slow because by default it's using a pure-perl backend (Math::BigInt::Calc). If you want to make it run faster, use some XS backend.

For example, this will use Math::BigInt::GMP:
perl -M'bigint=only,GMP' test.raku

and this Math::BigInt::Pari:
perl -M'bigint=only,Pari' test.raku

Anyway, bigint is maintained on CPAN (as a part of the bignum distribution), so any issues with it should be reported on its bugtracker, which is located here.

@xenu xenu closed this as completed Jul 11, 2020
@eserte
Copy link
Contributor

eserte commented Jul 11, 2020

On my system, GMP and raku's bigint implementation are comparable. Pari is somewhat slower:

$ time perl5.32.0 -Mbigint=only,Pari test.raku >/dev/null
perl5.32.0 -Mbigint=only,Pari test.raku > /dev/null  0.81s user 0.01s system 99% cpu 0.818 total

$ time perl5.32.0 -Mbigint=only,GMP test.raku >/dev/null
perl5.32.0 -Mbigint=only,GMP test.raku > /dev/null  0.66s user 0.00s system 99% cpu 0.662 total

$ time ~/rakudo/bin/raku test.raku >/dev/null 
~/rakudo/bin/raku test.raku > /dev/null  0.71s user 0.03s system 109% cpu 0.677 total

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants