Writing to stderr is 7x slower than writing to stdout
For some reason printing to stderr is significantly slower than printing to stdout.
I came across this because I realized that simple !QuickCheck properties are unnecessarily slow. !QuickCheck writes a lot of output to stderr, overriding old output with \b
.
Here are some stats:
GHC 7.6.1 / xterm / stdout:
main = sequence_ . replicate 10000 $ hPutStr stdout "foobarbaz" >> hFlush stdout
$ ghc main.hs && time ./main
...
real 0m0.070s
user 0m0.016s
sys 0m0.032s
GHC 7.6.1 / xterm / stderr:
main = sequence_ . replicate 10000 $ hPutStr stderr "foobarbaz" >> hFlush stderr
$ ghc main.hs && time ./main
...
real 0m0.538s
user 0m0.112s
sys 0m0.228s
If I do the same thing in C, then there is no performance difference.
Trac metadata
Trac field | Value |
---|---|
Version | 7.6.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Runtime System |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |