On Tue, 4 Jul 2017 12:17:12 -0700 (PDT), "'Shakin Billy' via Racket
Users" <racket-users@googlegroups.com> wrote:

>i couldn't make the inlining via define-syntax-rule work in typed racket. in 
>normal racket define-inline did'nt speed things up much but changing the code 
>of "acht-teiler" to:
>CODE--
>(define-syntax-rule (acht-teiler n)
>  (let loop ((i 2) (count 0) (quadrat 4) (steigung 5))
>    (cond ((= quadrat n) #f)
>          ((> quadrat n) (unsafe-fx= count 3))
>          ((unsafe-fx= (unsafe-fxmodulo n i) 0) (loop (unsafe-fx+ i 1) 
> (unsafe-fx+ count 1) (unsafe-fx+ quadrat steigung) (unsafe-fx+ steigung 2)))
>          (else (loop (unsafe-fx+ 1 i) count (unsafe-fx+ quadrat steigung) 
> (unsafe-fx+ steigung 2)))))
>  (loop 2 0 4 5)
>  )
>--CODE
>that is: no inner define but  a let brought the same speed up as using 
>typed-racket
>
>is let in general faster than define?

According to the docs, an internal define expands into a letrec form.
letrec introduces a set!-able binding whereas named-let (effectively)
just creates looping code.  

I am not familiar with the guts of the current compiler, but I can see
how they could be treated very differently.

https://docs.racket-lang.org/reference/syntax-model.html?q=define%20internal#%28part._intdef-body%29


>@ gneuner2
>jitting the function with a previous call yields only slightly better results 
>(on my mashine in the range of milliseconds)

That's to be expected given that the program is so small.

As I understand it, the current JIT implementation does little or no
optimization, so it is straightforward and very fast.  The point to
remember is that JIT is done incrementally, adding some overhead to
the 1st call of each function.  To get accurate timings, you need to
have exercised all the functions in the call chain at least once.

George

-- 
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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to