<div dir="ltr"><div>I'm seeing similar results on my end; I timed by first running "raco make" on both files, then timing "racket" on both. I think what we're seeing is a small startup time cost on Typed Racket. I ran a longer benchmark and Typed Racket edges out untyped Racket if I run a few million iterations (given this is such a short computation). The expressions I used are:<br>
<br></div><div>;; utest.rkt<br></div><div>(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></div><div>and<br><br></div>
<div>
;; test.rkt<br></div><div>(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></div><div><br></div><div>
I see just under 5 seconds for test.rkt and just over 5 seconds for utest.rkt. So there's a fraction of a second extra startup time for Typed Racket, but it takes less time for each subsequent computation, so the difference depends on how much "real" work you do after startup. I don't know what causes that startup cost, but hopefully this kind of benchmark will be useful to the Typed Racket maintainers in closing the gap for future versions. So, thanks for the example, Manfred!<br>
</div></div><div class="gmail_extra"><br clear="all"><div>Carl Eastlund</div>
<br><br><div class="gmail_quote">On Wed, May 8, 2013 at 5:32 AM, Manfred Lotz <span dir="ltr"><<a href="mailto:manfred.lotz@arcor.de" target="_blank">manfred.lotz@arcor.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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 checking.<br>
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 bad<br>
test?<br>
<br>
<br>
--<br>
Manfred<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
</blockquote></div><br></div>