[plt-scheme] re-open a bytes/string port?
On Fri, Jan 16, 2009 at 12:44 PM, YC <yinso.chen at gmail.com> wrote:
>
> 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?
>
> Thanks,
> yc
>
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.
Thanks,
yc
(define (test-port in count)
(for ((i (in-range 0 count)))
(peek-bytes 50 0 in )))
(test 500)
;; cpu time: 1 real time: 0 gc time: 0
;; cpu time: 0 real time: 1 gc time: 0
;; cpu time: 0 real time: 0 gc time: 0
(test 5000)
;; cpu time: 3 real time: 3 gc time: 0
;; cpu time: 34 real time: 35 gc time: 31
;; cpu time: 2 real time: 2 gc time: 0
(test 50000)
;; cpu time: 24 real time: 24 gc time: 0
;; cpu time: 27 real time: 27 gc time: 1
;; cpu time: 19 real time: 20 gc time: 2
(test 500000)
;; cpu time: 163 real time: 163 gc time: 3
;; cpu time: 173 real time: 173 gc time: 2
;; cpu time: 135 real time: 135 gc time: 9
(test 5000000)
;; cpu time: 1594 real time: 1598 gc time: 63
;; cpu time: 1761 real time: 1760 gc time: 61
;; cpu time: 1456 real time: 1456 gc time: 208
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090116/49b45998/attachment.html>