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 


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

Reply via email to