<div dir="ltr">On Wed, May 8, 2013 at 7:04 AM, Manfred Lotz <span dir="ltr"><<a href="mailto:manfred.lotz@arcor.de" target="_blank">manfred.lotz@arcor.de</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, 8 May 2013 06:19:27 -0400<br>
Carl Eastlund <<a href="mailto:cce@ccs.neu.edu">cce@ccs.neu.edu</a>> wrote:<br>
<br>
> I'm seeing similar results on my end; I timed by first running "raco<br>
> make" on both files, then timing "racket" on both. I think what<br>
> we're seeing is a small startup time cost on Typed Racket. I ran a<br>
> longer benchmark and Typed Racket edges out untyped Racket if I run a<br>
> few million iterations (given this is such a short computation). The<br>
> expressions I used are:<br>
><br>
> ;; utest.rkt<br>
> (void<br>
> (for/list {[i (in-range (* 10 1000 1000))]}<br>
> (distance<br>
> (pt (+ i 1.2) (+ i 2.1))<br>
> (pt (+ i 4.3) (+ i 5.6)))))<br>
><br>
> and<br>
><br>
> ;; test.rkt<br>
> (void<br>
> (for/list: : (Listof Float) {[i (in-range (* 10 1000 1000))]}<br>
> (distance<br>
> (pt (+ i 1.2) (+ i 2.1))<br>
> (pt (+ i 4.3) (+ i 5.6)))))<br>
><br>
><br>
> I see just under 5 seconds for test.rkt and just over 5 seconds for<br>
> utest.rkt. So there's a fraction of a second extra startup time for<br>
> Typed Racket, but it takes less time for each subsequent computation,<br>
> so the difference depends on how much "real" work you do after<br>
> startup. I don't know what causes that startup cost, but hopefully<br>
> this kind of benchmark will be useful to the Typed Racket maintainers<br>
> in closing the gap for future versions. So, thanks for the example,<br>
> Manfred!<br>
><br>
<br>
</div></div>Hi Carl,<br>
This is interesting. If I run it I have around 5 seconds for the typed<br>
version and around 4 seconds for the untyped version. My system is a<br>
64bit Linux.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Manfred<br></font></span></blockquote><div><br></div><div>What I ran was:<br><br> raco make test.rkt utest.rkt && time racket test.rkt && time racket utest.rkt<br><br></div><div>Just to make sure we're comparing apples to apples, does that give you the same results you saw before?<br>
</div><div> <span class="HOEnZb"><font color="#888888"></font></span><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"></span>> On Wed, May 8, 2013 at 5:32 AM, Manfred Lotz<br>
<div class="HOEnZb"><div class="h5">
> <<a href="mailto:manfred.lotz@arcor.de">manfred.lotz@arcor.de</a>> wrote:<br>
><br>
> > Hi there,<br>
> > I did a small test using typed racket.<br>
> ><br>
> > This is an example from the documentation:<br>
> ><br>
> > #lang typed/racket<br>
> > ;; test.rkt<br>
> ><br>
> > (struct: pt ([x : Float] [y : Float]))<br>
> ><br>
> > (: distance (pt pt -> Float))<br>
> > (define (distance p1 p2)<br>
> > (sqrt (+ (sqr (- (pt-x p2) (pt-x p1)))<br>
> > (sqr (- (pt-y p2) (pt-y p1))))))<br>
> ><br>
> > (distance (pt 1.2 2.1) (pt 4.3 5.6))<br>
> ><br>
> > This is the untyped version:<br>
> > #lang racket<br>
> > ;; utest.rkt<br>
> ><br>
> > (struct pt (x y))<br>
> ><br>
> > (define (distance p1 p2)<br>
> > (sqrt (+ (sqr (- (pt-x p2) (pt-x p1)))<br>
> > (sqr (- (pt-y p2) (pt-y p1))))))<br>
> ><br>
> > (distance (pt 1.2 2.1) (pt 4.3 5.6))<br>
> ><br>
> ><br>
> > Now running both:<br>
> > time racket test.rkt<br>
> > 4.675467891024383<br>
> > racket test.rkt 1.24s user 0.08s system 99% cpu 1.333 total<br>
> ><br>
> ><br>
> > time racket utest.rkt<br>
> > 4.675467891024383<br>
> > racket utest.rkt 0.22s user 0.03s system 99% cpu 0.248 total<br>
> ><br>
> ><br>
> > It seems the typed version needs a lot of time for the type<br>
> > checking. The time for time checking could be cut mostly by:<br>
> ><br>
> > raco exe test.rkt<br>
> > time ./test<br>
> > 4.675467891024383<br>
> > ./test 0.49s user 0.03s system 99% cpu 0.531 total<br>
> ><br>
> > But still runtime is more than twice as long. I could get the<br>
> > impression that typed racket is generally slower.<br>
> ><br>
> ><br>
> > Question: Is there any conclusion to be drawn from this (like that<br>
> > typed racket is slower than 'normal' racket)? Or is my test just a<br>
> > bad test?<br>
> ><br>
> ><br>
> > --<br>
> > Manfred<br></div></div></blockquote></div></div></div>