1module HeadersByteString (headers) where
3import Common (pathTo, rechunkBS)
4import Criterion.Main (bench, bgroup, nf, nfIO)
5import Criterion.Types (Benchmark)
6import HeadersByteString.Atto (request, response)
7import Network.Wai.Handler.Warp.RequestHeader (parseHeaderLines)
8import qualified Data.Attoparsec.ByteString.Char8 as B
9import qualified Data.Attoparsec.ByteString.Lazy as BL
10import qualified Data.ByteString.Char8 as B
12-- Note: In the benchmarks for parsing an http request
13-- from a strict bytestring, we consider warp's implementation,
14-- which has highly optimized code for handling the first
15-- line in particular. It's treatment of the headers
16-- is more relaxed from the treatment they are given by the
17-- attoparsec parser benchmarked here. Consequently, it
18-- is should not be possible to match its performance since
19-- it accepts header names with disallowed characters.
21headers :: IO Benchmark
23 req <- B.readFile =<< pathTo "http-request.txt"
24 resp <- B.readFile =<< pathTo "http-response.txt"
25 let reql = rechunkBS 4 req
26 respl = rechunkBS 4 resp
27 return $ bgroup "headers" [
29 bench "request" $ nf (B.parseOnly request) req
30 , bench "warp" $ nfIO (parseHeaderLines (B.split '\n' req))
31 , bench "response" $ nf (B.parseOnly response) resp
34 bench "request" $ nf (BL.parse request) reql
35 , bench "response" $ nf (BL.parse response) respl
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list