[plt-scheme] weird macro expansion performance

From: Pedro Pinto (ppinto at cs.cmu.edu)
Date: Sat Nov 22 18:26:02 EST 2003

Hi there,

I have been working on speeding up dot-scheme and I stumbled on what 
seems to be some odd behavior. Consider the test-macro below:

(require (lib "defmacro.ss"))

(define-macro (test-macro n)
  (define (gen-symbols n)
    (if (= n 0)
        '()
        (cons (string->symbol (string-append "sym" (number->string n)))
              (gen-symbols (- n 1)))))
  (cons 'begin (map (lambda (sym)
                      (list 'define sym 1))
                    (gen-symbols n))))


Expanding:
   
    (test-macro 15000)

Takes an inordinate amount of time on MzScheme (36 seconds on my  1.8 
Athlon)  with time growing linearly with n. DrScheme however seems to be 
15 to 20 times faster. Can anyone explain this difference and perhaps 
suggest a way to work around it in MzScheme?

Thanks in advance,

-pp

ps: v205 on Windows XP.





Posted on the users mailing list.