[plt-dev] Apply/List vs Call-with-values/vector->values
On Mon, Feb 22, 2010 at 10:37 AM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
> How should I expect these two lines to compare performance-wise:
>
> (apply make-prefab-struct
> (vector->list v))
>
> vs
>
> (call-with-values (lambda () (vector->values v))
> make-prefab-struct)
#lang scheme
(define v '#(foo 1 2 3))
(define k 1000000)
(define (run1)
(for ((i (in-range k)))
(apply make-prefab-struct
(vector->list v))))
(define (run2)
(for ((i (in-range k)))
(call-with-values (lambda () (vector->values v))
make-prefab-struct)))
(time (run1))
(time (run2))
cpu time: 1068 real time: 1075 gc time: 60
cpu time: 864 real time: 866 gc time: 44
--
sam th
samth at ccs.neu.edu