[racket] Performance of open-output-nowhere
Hi,
While trying to benchmark some of my code, I tried to minimize the time
spend on predefined IO functions, such as write-byte & friends, by using
the port returned by open-output-nowhere, expecting that it would be faster
than using, e.g., open-output-bytes, which has to accumulate the output.
However, contrary to my expectations, it turns out that using
open-output-nowhere is 10 times slower that using open-output-bytes.
Here is one example:
#lang racket
(define (test i n p)
(time (for ([l (in-range n)])
(write-byte i p))))
(test 123 100000000 (open-output-bytes))
(test 123 100000000 (open-output-nowhere))
I'm getting:
cpu time: 2860 real time: 2854 gc time: 32
cpu time: 28906 real time: 28904 gc time: 125
What's causing this difference?
Best,
António.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140724/feeb0c67/attachment.html>