1
Vote

AsyncStreamReader is many orders of magnitude slower than StreamReader

description

In testing some recent parsing work (HTTP request messages) I tried using AsyncStreamReader and found that it was many orders of magnitude slower than System.IO.StreamReader. I understand the trade-off in performance for the overhead of running async, but I was quite surprised at the result.
 
You can see the source here:
  1. StreamReader: source [1] tests [2]
  2. AsyncStreamReader: source [3] tests [4]
     
    What's the use case for this type? Am I using it wrong?
     
    [1] https://github.com/panesofglass/fracture/blob/http-parser/src/http/HttpParser.fs
    [2] https://github.com/panesofglass/fracture/blob/http-parser/tests/Http.Tests/HttpParserTest.fs
    [3] https://github.com/panesofglass/fracture/blob/async-http-parser/src/http/HttpParser.fs
    [4] https://github.com/panesofglass/fracture/blob/async-http-parser/tests/Http.Tests/HttpParserTest.fs

comments