Binary file for loop benchmark

This commit is contained in:
VyacheslavHashov 2017-07-12 22:44:07 +03:00
parent 4d123e9d2a
commit 3b6c72ec24
2 changed files with 10 additions and 4 deletions

View File

@ -156,8 +156,11 @@ benchLoop :: IO ()
benchLoop = do
counter <- newIORef 0 :: IO (IORef Word)
content <- newIORef "" :: IO (IORef BL.ByteString)
-- TODO read file
!bs <- B.readFile "1.txt"
-- File contains a PostgreSQL binary response on the query:
-- "SELECT typname, typnamespace, typowner, typlen, typbyval,
-- typcategory, typispreferred, typisdefined, typdelim,
-- typrelid, typelem, typarray from pg_type"
!bs <- B.readFile "bench/pg_type_rows.out"
writeIORef content . BL.cycle $ BL.fromStrict bs
let handler dm = case dm of
@ -170,7 +173,10 @@ benchLoop = do
let res = preBs <> ( BL.toStrict nb)
res `seq` pure res
tid <- forkIO . forever $ loopExtractDataRows newChunk handler
threadDelay 10000000
threadDelay $ durationSeconds * 1000 * 1000
killThread tid
s <- readIORef counter
print $ "Data messages parsed: " ++ show s
print $ "Data messages parsed per second: "
++ show (s `div` fromIntegral durationSeconds)
where
durationSeconds = 10

BIN
bench/pg_type_rows.out Normal file

Binary file not shown.