Is it because you're not using typed racket? On Aug 24, 2015 6:42 AM, "Rickard Andersson" <[email protected]> wrote:
> Hi, > > I noticed that the `divides?` function from math/number-theory seems to be > a huge bottleneck for whatever reason. > > This seems strange to me, but I figured I'd write to the list to see if > maybe there are trade-offs made that make sense mostly for big integers or > something. > > Example with (time): > > #lang racket/base > > (require (only-in math/number-theory divides?)) > > (define (divisible-by? x d) > (= (modulo x d) > 0)) > > (module+ main > (time > (for/sum ([x (in-range 3 500000000)]) > (if (3 . divides? . x) > x > 0))) ; cpu time: 96257 real time: 96166 gc time: 128 > (time > (for/sum ([x (in-range 3 500000000)]) > (if (x . divisible-by? . 3) > x > 0))) ; cpu time: 7277 real time: 7266 gc time: 0 > ) > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

