[racket-dev] Manual inlining destroys performance for this program
This short program generates a lot of closures, and thus doesn't run very fast.
#lang racket/base
(require racket/flonum)
(define (Point x0 x1 y0 y1)
(list (λ () (let ([x (- x1 x0)] [y (- y1 y0)])
(flsqrt (+ (* x x) (* y y)))))))
(define iter 1e4)
(for ([i (in-range iter)])
(define p (Point (random) (random) (random) (random)))
(define f (car p))
(for ([i (in-range 1e3)])
(f)))
I tried manually inlining `Point` by replacing `define` with
`define-syntax-rule`, and the program gets about 8x *slower*. I don't
have any idea why this is happening, especially since `Point` is
actually inlined by the optimizer in the `define` case.
Any idea why this might be?
Sam