<div dir="ltr"><div class="gmail_extra">I get :<br>> (let ((v (time (make-vector 50000000 0))))<br> (time (vector-length v))<br> (time (vector-length v))<br> (time (vector-length v))<br> (void))<br>cpu time: 188 real time: 191 gc time: 12<br>
cpu time: 0 real time: 0 gc time: 0<br>cpu time: 0 real time: 0 gc time: 0<br>cpu time: 0 real time: 0 gc time: 0<br><br></div><div class="gmail_extra">Which seems consistent to me.<br></div><div class="gmail_extra"><br>
</div>
Are you trying on the command line?<br><br>Laurent</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Mar 8, 2014 at 7:35 PM, Greg Hendershott <span dir="ltr"><<a href="mailto:greghendershott@gmail.com" target="_blank">greghendershott@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">As for length:<br>
<br>
(for ([i 3]) (collect-garbage))<br>
(let ((ls (time (make-list 50000000 0))))<br>
(time (length ls))<br>
(time (length ls))<br>
(time (length ls))<br>
(void))<br>
<br>
It's what I would expect:<br>
<br>
cpu time: 6733 real time: 6744 gc time: 6419<br>
cpu time: 141 real time: 141 gc time: 0<br>
cpu time: 145 real time: 145 gc time: 0<br>
cpu time: 142 real time: 142 gc time: 0<br>
<br>
- - - - -<br>
<br>
Next, thinking about 50000000 elements made me think about vectors,<br>
vector? and vector-length.<br>
<br>
This:<br>
<br>
(for ([i 3]) (collect-garbage))<br>
(let ((v (time (make-vector 50000000 0))))<br>
(time (vector-length v))<br>
(time (vector-length v))<br>
(time (vector-length v))<br>
(void))<br>
<br>
prints:<br>
<br>
cpu time: 182 real time: 183 gc time: 1<br>
cpu time: 315 real time: 315 gc time: 314<br>
cpu time: 0 real time: 0 gc time: 0<br>
cpu time: 0 real time: 0 gc time: 0<br>
<br>
Huh? The first call to vector-length takes even longer than making<br>
the vector (and, seems to be almost entirely gc).<br>
<br>
I would have guessed that make-vector would create a structure with<br>
the length already stored in it, and all vector-length calls would be<br>
essentially 0.<br>
<div class="HOEnZb"><div class="h5">____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div><br></div>