Hello Joe,<br>
<br><br><div class="gmail_quote">2012/2/22 Joe Gilray <span dir="ltr">&lt;<a href="mailto:jgilray@gmail.com">jgilray@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi Matthew,<div><br></div><div>Thanks for your help.  I really can&#39;t even pretend to understand the make-coroutine code but this is what I&#39;m seeing:</div><div><br></div><div>Original make-coroutine, without stream-ref pre-call =&gt; out of memory (1GB) when running (prime-pi 500000)</div>

</blockquote><div><br><br>I tried to run your code here and I also get out of memory in the first case.<br><br><br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


<div>Original make-coroutine, with stream-ref pre-call =&gt; runs (prime-pi 500000) in about .4 sec</div></blockquote><div><br><br>Just as a reference to the other results, here it gives: cpu time: 328 real time: 328 gc time: 94.<br>

<br><br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Alternate make-coroutine, with or without stream-ref pre-call =&gt; runs (prime-pi 500000) in about 28 sec<br>

<br></div></blockquote><div><br>With stream-ref pre-call: cpu time: 343 real time: 344 gc time: 78</div></div>Without: cpu time: 19609 real time: 19719 gc time: 9172<br><br><br><br><br>I changed `prime-pi&#39; into `prime-pi/acc&#39; as below and then I got the best results:<br>

<br>(define (prime-pi/acc n)<br>  (let loop-count ([candidate-stream primes]<br>                   [sum 0])<br>    (if (&gt; (stream-first candidate-stream) n) <br>        sum<br>        (loop-count (stream-rest candidate-stream) (add1 sum)))))<br>

<br><br>With original make-coroutine: cpu time: 234 real time: 235 gc time: 0<br>With Matthew&#39;s make-coroutine: cpu time: 187 real time: 187 gc time: 0<br><br><br><br>All measurements made from within DrRacket using (time (prime-pi 500000)) or (time (prime-pi/acc 500000)).<br>

<br>[]&#39;s<br><br>Rodolfo<br>