The above is of course supposed to say that `divides?` needed a few seconds more than the modulo example even in Typed Racket. Both were of course typed when running with TR.
On Mon, Aug 24, 2015 at 3:38 PM, Rickard Andersson < [email protected]> wrote: > Yes, that indeed seems to be the problem. However, even after managing to > wrap the types properly, using `divides?` still ended up being a bit > slower. Not dramatically slower, but still noticably and unexpectedly. > > As I'm not at all comfortable with Typed Racket I would appreciate if > someone could show how one would annotate the example minimally to give the > optimizer enough information to surpass Racket. As of this moment I haven't > really managed to see any improvement from using Typed Racket. It cut down > the time `divides?` needed to a few seconds more than Racket. Otherwise, it > had no effect (on the other example either). > > As a point of curiosity; I had to work around the fact that apparently > there were not enough type annotations by wrapping the `for`s in functions > and typing them accordingly. Is there a better way to do this? > > I'm currently trying to compare some performance between OCaml, C and > Racket and I'm currently using the aforementioned example. > > Here are some timings: > > |> time racket divides.rkt; time ./divides_c; time ./divides_ocaml > 41666666583333333 > racket divides.rkt 7.32s user 0.02s system 100% cpu 7.336 total > 41666666583333333 > ./divides_c 0.49s user 0.00s system 99% cpu 0.488 total > 41666666583333333 > ./divides_ocaml 0.75s user 0.00s system 99% cpu > > The idea is to see how fast one can make the following: > > #lang racket/base > > (define (divisible-by? x d) > (= (modulo x d) > 0)) > > (module+ main > (for/sum ([x (in-range 3 500000000)]) > (if (x . divisible-by? . 3) > x > 0)) > ) > > On Mon, 24 Aug 2015, Pierpaolo Bernardi wrote: > > On Mon, Aug 24, 2015 at 1:25 PM, Jens Axel Søgaard >> <[email protected]> wrote: >> >>> It looks very odd to me. >>> >> >> Maybe this is due to calling TR functions from plain Racket? >> > -- 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.

