[racket] generator performance

From: Patrick Useldinger (uselpa.list at gmail.com)
Date: Sun Sep 16 09:08:09 EDT 2012

Hello

I have a Python program doing some intensive computing and would like to 
port it to Racket for performance reasons.

I use a generator in Python which has a very low overhead. While writing 
some test programs, I seem to have an substantial overhead on using 
generators in Racket:

Callback version:
pu at pumbair:~/Projects/LanguageBenchmark$ time ./combis.rkt 20 2 n a
combis_a: total 1048576
real	0m0.849s
user	0m0.694s
sys	0m0.140s

Generator version:
pu at pumbair:~/Projects/LanguageBenchmark$ time ./combis.rkt 20 2 n b
combis_b: total 1048576
real	0m18.022s
user	0m15.738s
sys	0m1.821s

so the generator version is more that 20 times slower (and way slower 
than the equivalent Python code).

If this is due to my Racket code being sub-optimal, I'd love to have 
some help on this.

Code is at http://pastebin.com/Dtz76e5f .

Regards,
-Patrick

Posted on the users mailing list.