Opened 5 years ago
Last modified 3 years ago
#18019 new enhancement
Slow performance when running mpfi in Sage (compairing to Perl)
Reported by: | akhi | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-6.6 |
Component: | algebra | Keywords: | mpfi, RIF, sagedays 64 |
Cc: | nthiery, saliola, merbst, zimmerma | Merged in: | |
Authors: | Akhilesh P. | Reviewers: | |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
I have wrote a simple program for addition and multiplication in Sage using mpfi . same thing when I runs in Perl it took much lesser time Example::
sage: %runfile test3.sage 3.14159265358979323846264338328? is the mpfi number 10.4374148846 seconds time for 1000000 divisions sage: %runfile test3a.sage 3.14159265358979323846264338328? is the mpfi number 8.87430405617 seconds time for 1000000 additions sage: akhi@akhi:~$ perl test3.pl [3.1415926535897932384626433832793,3.1415926535897932384626433832825] is the mpfi number total time = 2 seconds time for 1000000 divisions akhi@akhi:~$ perl test3a.pl [3.1415926535897932384626433832793,3.1415926535897932384626433832825] is the mpfi number total time = 2 seconds time for 1000000 additions akhi@akhi:~$
Attachments (4)
Change History (11)
Changed 5 years ago by
Changed 5 years ago by
Changed 5 years ago by
Changed 5 years ago by
comment:1 Changed 5 years ago by
- Description modified (diff)
comment:2 Changed 5 years ago by
- Keywords mpfi RIF sagedays 64 added
comment:3 Changed 5 years ago by
- Cc zimmerma added
comment:4 Changed 3 years ago by
comment:5 Changed 3 years ago by
When you write b = n/res
, note that n
is a Python int and res an element of RIF
, so Sage has to resolve the coercion to find a common parent, which takes time. Instead, you can transform n
to an element of RIF
by writing instead : b = RIF(n)/res
. The timings should decrease (Debian seems not to distribute MPFI for Perl, so i couldn't do the comparison).
comment:6 Changed 3 years ago by
I have made the modifications that you suggested but still Perl works much faster
sage: load("test3.sage")
3.14159265358979323846264338328? is the mpfi number
4.71341490746 seconds time for 1000000 divisions
akhi@akhi:~$ perl test3.pl
[3.1415926535897932384626433832793,3.1415926535897932384626433832825] is the mpfi number
total time = 2 seconds time for 1000000 divisions
comment:7 Changed 3 years ago by
perl mpfi library is there at cpan http://search.cpan.org/~sisyphus/Math-MPFI-0.05/MPFI.pm
Akhilesh is sitting next to me here at Sage Days 75. Would you have any insight about the speed difference between Sage and Perl here?
Amitiés,