ptr-peeker 0.2 → 0.2.0.1
raw patch · 2 files changed
+17/−14 lines, 2 filesdep ~tasty-quickcheckPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: tasty-quickcheck
API changes (from Hackage documentation)
Files
- ptr-peeker.cabal +2/−2
- src/bench/Main.hs +15/−12
ptr-peeker.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: ptr-peeker-version: 0.2+version: 0.2.0.1 synopsis: High-performance composable binary data deserializers description: A high-performance binary data deserialization library providing a type-safe, flexible and composable abstraction over manipulations on pointers.@@ -118,7 +118,7 @@ rerebase <2, tasty >=1.4.1 && <2, tasty-hunit >=0.10.0.3 && <0.11,- tasty-quickcheck >=0.10.1.2 && <0.11,+ tasty-quickcheck >=0.10.1.2 && <0.12, benchmark bench import: executable
src/bench/Main.hs view
@@ -1,9 +1,12 @@+module Main (main) where+ import Criterion.Main import Data.Serialize qualified as Cereal import Data.Store qualified as Store import Data.Vector qualified as V import Data.Vector.Unboxed qualified as Vu-import PtrPeeker qualified as Pb+import GHC.Stack (HasCallStack)+import PtrPeeker qualified as PtrPeeker import Test.Tasty.HUnit qualified as Tasty import Prelude @@ -19,10 +22,10 @@ correctDecoding = (1, 2, 3) subjects = [ ( "ptr-peeker/fixed",- hush . Pb.runVariableOnByteString (Pb.fixed $ (,,) <$> Pb.leSignedInt4 <*> Pb.leSignedInt4 <*> Pb.leSignedInt4)+ hush . PtrPeeker.runVariableOnByteString (PtrPeeker.fixed $ (,,) <$> PtrPeeker.leSignedInt4 <*> PtrPeeker.leSignedInt4 <*> PtrPeeker.leSignedInt4) ), ( "ptr-peeker/variable",- hush . Pb.runVariableOnByteString ((,,) <$> Pb.fixed Pb.leSignedInt4 <*> Pb.fixed Pb.leSignedInt4 <*> Pb.fixed Pb.leSignedInt4)+ hush . PtrPeeker.runVariableOnByteString ((,,) <$> PtrPeeker.fixed PtrPeeker.leSignedInt4 <*> PtrPeeker.fixed PtrPeeker.leSignedInt4 <*> PtrPeeker.fixed PtrPeeker.leSignedInt4) ), ( "store", hush . Store.decode @(Int32, Int32, Int32)@@ -41,9 +44,9 @@ subjects = [ ( "ptr-peeker", let decoder = do- size <- Pb.fixed Pb.leSignedInt4- Pb.fixed $ Pb.fixedArray @Vu.Vector Pb.leSignedInt4 $ fromIntegral size- in hush . Pb.runVariableOnByteString decoder+ size <- PtrPeeker.fixed PtrPeeker.leSignedInt4+ PtrPeeker.fixed $ PtrPeeker.fixedArray @Vu.Vector PtrPeeker.leSignedInt4 $ fromIntegral size+ in hush . PtrPeeker.runVariableOnByteString decoder ), ( "store", let decoder = do@@ -68,12 +71,12 @@ subjects = [ ( "ptr-peeker", let decoder = do- size <- Pb.fixed Pb.leSignedInt8- Pb.variableArray @V.Vector byteStringDecoder $ fromIntegral size+ size <- PtrPeeker.fixed PtrPeeker.leSignedInt8+ PtrPeeker.variableArray @V.Vector byteStringDecoder $ fromIntegral size byteStringDecoder = do- size <- Pb.fixed Pb.leSignedInt8- Pb.fixed $ Pb.byteArrayAsByteString $ fromIntegral size- in hush . Pb.runVariableOnByteString decoder+ size <- PtrPeeker.fixed PtrPeeker.leSignedInt8+ PtrPeeker.fixed $ PtrPeeker.byteArrayAsByteString $ fromIntegral size+ in hush . PtrPeeker.runVariableOnByteString decoder ), ( "store", hush . Store.decode@@ -94,7 +97,7 @@ defaultMain groups -- | Test functions and create a benchmark group out of them.-initGroup :: (Eq a, Show a, NFData a) => String -> ByteString -> a -> [(String, ByteString -> Maybe a)] -> IO Benchmark+initGroup :: (HasCallStack) => (Eq a, Show a, NFData a) => String -> ByteString -> a -> [(String, ByteString -> Maybe a)] -> IO Benchmark initGroup name input correctDecoding subjects = do fmap (bgroup name) . forM subjects $ \(name, f) -> do Tasty.assertEqual name (Just correctDecoding) (f input)