On Wed, 8 May 2013 07:31:37 -0400 Carl Eastlund <c...@ccs.neu.edu> wrote:
> On Wed, May 8, 2013 at 7:04 AM, Manfred Lotz > <manfred.l...@arcor.de> wrote: > > > On Wed, 8 May 2013 06:19:27 -0400 > > Carl Eastlund <c...@ccs.neu.edu> wrote: > > > > > 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: > > > > > > ;; utest.rkt > > > (void > > > (for/list {[i (in-range (* 10 1000 1000))]} > > > (distance > > > (pt (+ i 1.2) (+ i 2.1)) > > > (pt (+ i 4.3) (+ i 5.6))))) > > > > > > and > > > > > > ;; test.rkt > > > (void > > > (for/list: : (Listof Float) {[i (in-range (* 10 1000 1000))]} > > > (distance > > > (pt (+ i 1.2) (+ i 2.1)) > > > (pt (+ i 4.3) (+ i 5.6))))) > > > > > > > > > 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! > > > > > > > Hi Carl, > > This is interesting. If I run it I have around 5 seconds for the > > typed version and around 4 seconds for the untyped version. My > > system is a 64bit Linux. > > > > -- > > Manfred > > > > What I ran was: > > raco make test.rkt utest.rkt && time racket test.rkt && time racket > utest.rkt > > Just to make sure we're comparing apples to apples, does that give > you the same results you saw before? > > Yep, I did something different: Now going your way I get 3.7 sec for typed and 4.1 sec for untyped. It is interesting to note that if I do raco exe for both the executables run longer: 4 sec for typed and 4.7 sec for untyped. > > > On Wed, May 8, 2013 at 5:32 AM, Manfred Lotz > > > <manfred.l...@arcor.de> wrote: > > > > > > > Hi there, > > > > I did a small test using typed racket. > > > > > > > > This is an example from the documentation: > > > > > > > > #lang typed/racket > > > > ;; test.rkt > > > > > > > > (struct: pt ([x : Float] [y : Float])) > > > > > > > > (: distance (pt pt -> Float)) > > > > (define (distance p1 p2) > > > > (sqrt (+ (sqr (- (pt-x p2) (pt-x p1))) > > > > (sqr (- (pt-y p2) (pt-y p1)))))) > > > > > > > > (distance (pt 1.2 2.1) (pt 4.3 5.6)) > > > > > > > > This is the untyped version: > > > > #lang racket > > > > ;; utest.rkt > > > > > > > > (struct pt (x y)) > > > > > > > > (define (distance p1 p2) > > > > (sqrt (+ (sqr (- (pt-x p2) (pt-x p1))) > > > > (sqr (- (pt-y p2) (pt-y p1)))))) > > > > > > > > (distance (pt 1.2 2.1) (pt 4.3 5.6)) > > > > > > > > > > > > Now running both: > > > > time racket test.rkt > > > > 4.675467891024383 > > > > racket test.rkt 1.24s user 0.08s system 99% cpu 1.333 total > > > > > > > > > > > > time racket utest.rkt > > > > 4.675467891024383 > > > > racket utest.rkt 0.22s user 0.03s system 99% cpu 0.248 total > > > > > > > > > > > > It seems the typed version needs a lot of time for the type > > > > checking. The time for time checking could be cut mostly by: > > > > > > > > raco exe test.rkt > > > > time ./test > > > > 4.675467891024383 > > > > ./test 0.49s user 0.03s system 99% cpu 0.531 total > > > > > > > > But still runtime is more than twice as long. I could get the > > > > impression that typed racket is generally slower. > > > > > > > > > > > > Question: Is there any conclusion to be drawn from this (like > > > > that typed racket is slower than 'normal' racket)? Or is my > > > > test just a bad test? > > > > > > > > > > > > -- > > > > Manfred > > > ____________________ Racket Users list: http://lists.racket-lang.org/users