@@ -31,7 +31,7 @@ import Streamly.Internal.Data.Unbox
31import Control.DeepSeq (force)
31import Control.DeepSeq (force)
32import Test.QuickCheck (oneof, generate)
32import Test.QuickCheck (oneof, generate)
33import Streamly.Internal.Data.Unbox (newBytes, MutableByteArray)
33import Streamly.Internal.Data.Unbox (newBytes, MutableByteArray)
34−import Streamly.Internal.Data.Serialize
34+import Streamly.Internal.Data.Serialize hiding (encode)
37#ifdef USE_TH
37#ifdef USE_TH
@@ -353,6 +353,17 @@ pokeTimes val times = do
353 arr <- newBytes n
353 arr <- newBytes n
354 loopWith times poke arr val
354 loopWith times poke arr val
356+{-# INLINE encode #-}
357+encode :: SERIALIZE_CLASS a => a -> IO ()
361+ SERIALIZE_OP 0 arr val >> return ()
363+{-# INLINE encodeTimes #-}
364+encodeTimes :: SERIALIZE_CLASS a => a -> Int -> IO ()
365+encodeTimes val times = loop times encode val
356{-# INLINE peek #-}
367{-# INLINE peek #-}
357peek :: forall a. (NFData a, SERIALIZE_CLASS a) =>
368peek :: forall a. (NFData a, SERIALIZE_CLASS a) =>
358 (a, Int) -> MutableByteArray -> IO ()
369 (a, Int) -> MutableByteArray -> IO ()
@@ -478,11 +489,13 @@ allBenchmarks tInt lInt times =
479 , benchConst "poke" (const pokeTimes) times
490 , benchConst "poke" (const pokeTimes) times
480 , benchConst "pokeWithSize" (const pokeTimesWithSize) times
491 , benchConst "pokeWithSize" (const pokeTimesWithSize) times
492+ , benchConst "encode" (const encodeTimes) times
481 , benchConst "peek" peekTimes times
493 , benchConst "peek" peekTimes times
482 , benchConst "roundtrip" (const roundtrip) times
494 , benchConst "roundtrip" (const roundtrip) times
483#ifndef USE_UNBOX
495#ifndef USE_UNBOX
484 , benchVar "poke" (const pokeTimes) tInt lInt 1
496 , benchVar "poke" (const pokeTimes) tInt lInt 1
485 , benchVar "pokeWithSize" (const pokeTimesWithSize) tInt lInt 1
497 , benchVar "pokeWithSize" (const pokeTimesWithSize) tInt lInt 1
498+ , benchVar "encode" (const encodeTimes) tInt lInt 1
486 , benchVar "peek" peekTimes tInt lInt 1
499 , benchVar "peek" peekTimes tInt lInt 1
487 , benchVar "roundtrip" (const roundtrip) tInt lInt 1
500 , benchVar "roundtrip" (const roundtrip) tInt lInt 1