<br><div class="gmail_quote">On Fri, Jan 16, 2009 at 12:44 PM, YC <span dir="ltr"><<a href="mailto:yinso.chen@gmail.com">yinso.chen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><div class="gmail_quote"><div>Thanks for verifying, Matthew. I did a quick test and found that the overhead is minimal. I also compared against `substring` as reference, and found that regular string port still has a bit of overhead above substring. Is the overhead due to synchronization primitives?<br>
<br>Thanks,<br>yc<br></div></div></blockquote><div><br>I just realized that I double counted on `test-port` as I did two separate operation - `read-bytes` & `file-position`. By changing it to `peek-bytes` the test is now fairer to the ports. A slight overhead of bytes port still exists over substring though. And the wrapped port's overhead is smaller as well. <br>
<br>Thanks,<br>yc<br><br>(define (test-port in count)<br> (for ((i (in-range 0 count)))<br> (peek-bytes 50 0 in )))<br><br>(test 500)<br>
;; cpu time: 1 real time: 0 gc time: 0<br>;; cpu time: 0 real time: 1 gc time: 0<br>;; cpu time: 0 real time: 0 gc time: 0<br><br>(test 5000)<br>
;; cpu time: 3 real time: 3 gc time: 0<br>;; cpu time: 34 real time: 35 gc time: 31<br>;; cpu time: 2 real time: 2 gc time: 0<br><br>(test 50000)<br>
;; cpu time: 24 real time: 24 gc time: 0<br>;; cpu time: 27 real time: 27 gc time: 1<br>;; cpu time: 19 real time: 20 gc time: 2<br><br>(test 500000)<br>
;; cpu time: 163 real time: 163 gc time: 3<br>;; cpu time: 173 real time: 173 gc time: 2<br>;; cpu time: 135 real time: 135 gc time: 9<br><br>(test 5000000)<br>
;; cpu time: 1594 real time: 1598 gc time: 63<br>;; cpu time: 1761 real time: 1760 gc time: 61<br>;; cpu time: 1456 real time: 1456 gc time: 208<br><br></div></div>