[racket-dev] Can someone tell whats wrong with this?

From: Hari Prashanth (krhari at ccs.neu.edu)
Date: Fri Feb 25 19:29:17 EST 2011

The program is killed when the call to `collect' inside for loop is 
commented... I am using a fairly recent version of Racket...

#lang racket/load

(module RACKETSET racket/base

  (require (prefix-in rk: racket/set))

  (define list1 (build-list 1000000 add1))
  (define list2 (build-list 1000000 (λ (x) (+ x 1000000))))
  (define set1 (apply rk:set list1))
  (define set2 (apply rk:set list2))

  (display "Racket sets\n")
  (define (collect)
  (define sets
    (for ([i (in-range 10)])
      (time (rk:set-union set1 set2))

swamiji at ubuntu:~/Desktop/krhari/TS$ raco make set-benchmark.rkt
swamiji at ubuntu:~/Desktop/krhari/TS$ racket set-benchmark.rkt
Racket sets
cpu time: 5800 real time: 5810 gc time: 520
cpu time: 6670 real time: 7041 gc time: 1390
cpu time: 5890 real time: 10478 gc time: 620
swamiji at ubuntu:~/Desktop/krhari/TS$

Posted on the dev mailing list.