mirror of
https://github.com/nikita-volkov/hasql.git
synced 2024-11-23 10:42:19 +03:00
51 lines
1.3 KiB
Haskell
51 lines
1.3 KiB
Haskell
module Main where
|
|
|
|
import Main.Prelude
|
|
import Criterion.Main
|
|
import qualified Hasql as H
|
|
import qualified Hasql.Serialization as HS
|
|
import qualified Hasql.Deserialization as HD
|
|
import qualified Main.Queries as Q
|
|
|
|
|
|
main =
|
|
H.connect settings >>= either (fail . show) use
|
|
where
|
|
settings =
|
|
H.ParametricSettings host port user password database
|
|
where
|
|
host = "localhost"
|
|
port = 5432
|
|
user = "postgres"
|
|
password = ""
|
|
database = "postgres"
|
|
use connection =
|
|
defaultMain
|
|
[
|
|
bgroup "decoding"
|
|
[
|
|
bgroup "1 column"
|
|
[
|
|
bench "1 row" $ nfIO $! query () $! Q.select1 1
|
|
,
|
|
bench "100 rows" $ nfIO $! query () $! Q.select1 100
|
|
,
|
|
bench "10000 rows" $ nfIO $! query () $! Q.select1 10000
|
|
]
|
|
,
|
|
bgroup "4 columns"
|
|
[
|
|
bench "1 row" $ nfIO $! query () $! Q.select4 1
|
|
,
|
|
bench "100 rows" $ nfIO $! query () $! Q.select4 100
|
|
,
|
|
bench "10000 rows" $ nfIO $! query () $! Q.select4 10000
|
|
]
|
|
]
|
|
]
|
|
where
|
|
query :: a -> H.Query a b -> IO b
|
|
query params query =
|
|
{-# SCC "query" #-}
|
|
H.query connection query params >>= either (fail . show) pure
|