[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 :)

Marc Feeley feeley at iro.umontreal.ca
Wed Apr 24 19:55:29 EDT 2013


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

Marc




More information about the Gambit-list mailing list