tmp-postgres 1.31.0.0 → 1.31.0.1
raw patch · 4 files changed
+37/−15 lines, 4 files
Files
- CHANGELOG.md +4/−0
- benchmark/Main.hs +31/−10
- src/Database/Postgres/Temp/Internal.hs +1/−4
- tmp-postgres.cabal +1/−1
CHANGELOG.md view
@@ -1,5 +1,9 @@ Changelog for tmp-postgres +1.31.0.1+ #227 remove mention of defaultPostgresConf in doc+ #228 add track_io_timing = on to verboseConfig+ 1.31.0.0 #224 Remove defaultPostgresConf #223 Doc fixes
benchmark/Main.hs view
@@ -5,9 +5,11 @@ import Criterion.Main hiding (defaultConfig) import Data.String import Database.Postgres.Temp.Internal+import Database.Postgres.Temp.Internal.Core import Database.Postgres.Temp.Internal.Config import qualified Database.PostgreSQL.Simple as PG import System.IO.Temp (createTempDirectory, withTempDirectory)+import qualified Database.PostgreSQL.Simple.Options as Options data Once a = Once { unOnce :: a } @@ -42,18 +44,21 @@ bracket (PG.connectPostgreSQL theConnectionString) PG.close $ \conn -> void $ PG.execute_ conn "INSERT INTO foo1 (id) VALUES (1)" -setupCache :: IO Cache-setupCache = do- cacheInfo <- setupInitDbCache defaultCacheConfig+setupCache :: Bool -> IO Cache+setupCache cow = do+ cacheInfo <- setupInitDbCache (defaultCacheConfig { cacheUseCopyOnWrite = cow}) void (withConfig (defaultConfig <> cacheConfig cacheInfo) (const $ pure ())) pure cacheInfo setupWithCache :: (Config -> Benchmark) -> Benchmark-setupWithCache f = envWithCleanup setupCache cleanupInitDbCache $ f . (defaultConfig <>) . cacheConfig+setupWithCache f = envWithCleanup (setupCache True) cleanupInitDbCache $ f . (defaultConfig <>) . cacheConfig +setupWithCacheNoCow :: (Config -> Benchmark) -> Benchmark+setupWithCacheNoCow f = envWithCleanup (setupCache False) cleanupInitDbCache $ f . (defaultConfig <>) . cacheConfig+ setupCacheAndSP :: IO (Cache, Snapshot, Once Config) setupCacheAndSP = do- cacheInfo <- setupCache+ cacheInfo <- setupCache True let theCacheConfig = defaultConfig <> cacheConfig cacheInfo sp <- either throwIO pure <=< withConfig theCacheConfig $ \db -> do migrateDb db@@ -74,7 +79,7 @@ setupCacheAndAction :: IO (Cache, FilePath, Once Config) setupCacheAndAction = do- cacheInfo <- setupCache+ cacheInfo <- setupCache True snapshotDir <- createTempDirectory "/tmp" "tmp-postgres-bench-cache" let theCacheConfig = defaultConfig <> cacheConfig cacheInfo @@ -96,15 +101,22 @@ , bench "withConfig no --no-sync" $ whnfIO $ withConfig defaultConfigDefaultInitDb $ const $ pure () - , bench "withConfig silent" $ whnfIO $- withConfig defaultConfig $ const $ pure ()+ , bench "withConfig verbose" $ whnfIO $+ withConfig verboseConfig $ const $ pure () + , bench "withConfig db create" $ whnfIO $+ withConfig (optionsToDefaultConfig (mempty { Options.dbname = pure "test" } )) $+ const $ pure ()++ , setupWithCacheNoCow $ \theConfig -> bench "withConfig silent cache no cow" $ whnfIO $+ withConfig theConfig $ const $ pure ()+ , setupWithCache $ \theCacheConfig -> bench "withConfig silent cache" $ whnfIO $ withConfig theCacheConfig $ const $ pure () , bench "with migrate 10x" $ whnfIO $ replicateM 10 $ withConfig defaultConfig $ \db -> migrateDb db >> testQuery db-+{- , setupWithCache $ \theCacheConfig -> do bench "with migrate 10x and cache" $ whnfIO $ withConfig theCacheConfig $ \_ -> do replicateM_ 10 $ withConfig theCacheConfig $ \db ->@@ -126,7 +138,7 @@ replicateM_ 10 $ either throwIO pure =<< flip withConfig testQuery =<< either throwIO pure =<< cacheAction snapshotDir migrateDb theCacheConfig-+-} , setupWithCacheAndSP $ \theConfig -> bench "withConfig pre-setup with withSnapshot" $ whnfIO $ void $ withConfig theConfig $ const $ pure () @@ -139,6 +151,15 @@ , bench "withSnapshot" $ perRunEnvWithCleanup (either throwIO (pure . Once) =<< startConfig defaultConfig) (stop . unOnce) $ \ ~(Once db) -> void $ withSnapshot db $ const $ pure () + , bench "stopGracefully" $ perRunEnvWithCleanup (either throwIO (pure . Once) =<< start) (stop . unOnce) $+ \ ~(Once db) -> do+ void $ stopPostgresGracefully db+ stop db+ , bench "stop" $ perRunEnvWithCleanup (either throwIO (pure . Once) =<< start) (stop . unOnce) $ \ ~(Once db) -> stop db++ , bench "stop serial" $ perRunEnvWithCleanup (either throwIO (pure . Once) =<< start) (stop . unOnce) $+ \ ~(Once DB {..}) ->+ stopPlan dbPostgresProcess >> cleanupConfig dbResources ]
src/Database/Postgres/Temp/Internal.hs view
@@ -188,10 +188,6 @@ } @ -- This is common enough there is `defaultPostgresConf` which- is a helper to do this.- As an alternative to using 'defaultConfig' one could create a config from connections parameters using 'optionsToDefaultConfig'. @@ -249,6 +245,7 @@ , ("log_error_verbosity", "default") , ("log_line_prefix", "'%t [%p]: '") , ("lc_messages", "'C'")+ , ("track_io_timing", "on") ] {-|
tmp-postgres.cabal view
@@ -1,5 +1,5 @@ name: tmp-postgres-version: 1.31.0.0+version: 1.31.0.1 synopsis: Start and stop a temporary postgres description: Start and stop a temporary postgres. See README.md homepage: https://github.com/jfischoff/tmp-postgres#readme