[racket-dev] for/vector much slower than vector-set! ?
I was testing the speed of vector creation, and I was surprised to see that for/vector seems much slower than using 'for' with an explicit vector-set!
(printf "let's try just generating a big vector.\n")
(rtavg (for/vector ([i (in-range (* 100 sr))]) 0.243))
(printf "\n\n")
(printf "how about with explicit vector-set! ?\n")
(rtavg
(let ([v (make-vector (* 100 sr))])
(for ([i (in-range (vector-length v))])
(vector-set! v i 0.243))))
(printf "\n\n")
==>
let's try just generating a big vector.
2.218 seconds
how about with explicit vector-set! ?
0.089 seconds
Does the first one somehow have to check some things that the second one doesn't?
John
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4624 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20110718/66149bfa/attachment.p7s>