hasql/benchmark/Main/Queries.hs

30 lines
811 B
Haskell
Raw Normal View History

2015-11-16 22:06:47 +03:00
module Main.Queries where
import Main.Prelude
import qualified Hasql as H
import qualified Hasql.Serialization as HS
import qualified Hasql.Deserialization as HD
2015-11-20 09:28:09 +03:00
select1 :: Int -> H.Query () ([] Int64)
2015-11-16 22:06:47 +03:00
select1 amount =
2015-11-21 09:58:43 +03:00
{-# SCC "select1" #-}
2015-11-16 22:06:47 +03:00
(sql, mempty, deserializer, True)
where
2015-11-21 09:58:43 +03:00
!sql =
2015-11-16 22:06:47 +03:00
"values " <>
mconcat (intersperse ", " (replicate amount "(1)"))
deserializer =
2015-11-20 09:28:09 +03:00
HD.rowsList (HD.value HD.int8)
2015-11-16 22:06:47 +03:00
2015-11-20 09:28:09 +03:00
select4 :: Int -> H.Query () ([] (Int64, Int64, Int64, Int64))
2015-11-16 22:06:47 +03:00
select4 amount =
2015-11-21 09:58:43 +03:00
{-# SCC "select4" #-}
2015-11-16 22:06:47 +03:00
(sql, mempty, deserializer, True)
where
2015-11-21 09:58:43 +03:00
!sql =
2015-11-16 22:06:47 +03:00
"values " <>
mconcat (intersperse ", " (replicate amount "(1, 2, 3, 4)"))
deserializer =
2015-11-20 09:28:09 +03:00
HD.rowsList ((,,,) <$> HD.value HD.int8 <*> HD.value HD.int8 <*> HD.value HD.int8 <*> HD.value HD.int8)