[gambit-list] Simple benchmark of |->integer| and |->flonum| on integer, flonum and rational input. For the further if you have any idea of a definition faster than (inexact->exact (floor n)) feel free to share :)

Mikael mikael.rcv at gmail.com
Thu Apr 25 08:54:32 EDT 2013


Hi!

Aha.

Is there any difference between ##flonum->fixnum , ##flonum.->fixnum and
##fl->fx?

(And in the other direction, ##fixnum->flonum , ##flonum.<-fixnum
and ##fl<-fx )

Brgds

2013/4/25 Marc Feeley <feeley at iro.umontreal.ca>

>
> On 2013-04-24, at 7:55 PM, Marc Feeley <feeley at iro.umontreal.ca> wrote:
>
> >
> > On 2013-04-24, at 3:32 PM, Mikael <mikael.rcv at gmail.com> wrote:
> >
> >> Ah, realized that Gambit makes a difference internally between 1e25 and
> 10000000000000000000000000 . So added a test also for the latter.
> >>
> >>
> >> Got 6,794,405 per second for |->integer| - fair enough!
> >>
> >> And got 384,459 for |->flonum| - could be faster.
> >>
> >>
> >>> (->integer-test5)
> >> 6794405.8
> >>> (->flonum-test5)
> >> 384459.2
> >>
> >>
> >> Def:
> >> (define (->integer-test5) (test (->integer 10000000000000000000000000)))
> >>
> >> (define (->flonum-test5) (test (->flonum 10000000000000000000000000)))
> >>
> >
> > Here are some other options:
> >
> >> (##flonum.->fixnum 1.5e6)
> > 1500000
> >> (##flonum.->exact-int 1.5e20)
> > 150000000000000000000
> >> (##flonum.<-fixnum 123456)
> > 123456.
> >> (##flonum.<-exact-int 1234567890123456)
> > 1.234567890123456e15
>
> And also these primitives:
>
> > (##flonum->fixnum 12.3)
> 12
> > (##fixnum->flonum 123)
> 123.
>
> These are inlined by gsc, so they should run at the same speed as C.
>
> Marc
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20130425/f1d899a4/attachment.htm>


More information about the Gambit-list mailing list