Closed redneb closed 6 years ago
Just to clarify, I don't think we can improve the performance of Show (Rounded r p)
by improving showFloat
from base
. showFloat
is too general. I think an ad-hoc instance for Rounded
is needed, just like how there is an ad-hoc instance for Show Integer
. The latter is defined in GHC.Show
and is super-optimized, so maybe it's a good idea to use it somehow.
hmpfr has a Show instance based on mpfr_get_str and it is much faster than rounded's Show instance. (See Conversion.hs.) This binding was written by Aleš Bizjak long time ago. I do not know how hard it is to make a similar binding in rounded.
That definitely seems worth doing and doesn't look like a difficult port.
fixed by https://github.com/ekmett/rounded/pull/27 merge
Currently the
Show
instance usesshowFloat
fromNumeric
frombase
. Unfortunately, that function is rather slow when it comes to numbers with a large number of digits. For example, calculating the first 100,000 decimal digits of π (hence 100,001 significant decimal digits or 332197 significant binary digits) with the following:takes 6 seconds to complete in my system. On the other hand, if I use the
Show
instance ofInteger
to find the same digits, e.g. withtakes only 0.15 seconds to complete in the same system.