Skip to content

Commit

Permalink
add persist
Browse files Browse the repository at this point in the history
  • Loading branch information
minad committed Oct 29, 2018
1 parent ed50c1d commit d269776
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
.cabal-sandbox/
.stack-work
cabal.sandbox.config
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The summary tables list, for every test, all libraries that are within 30% of th
To merge all measures in a concrete use case, we estimate the total transfer time at different transmission speeds, that's to say the the time that it takes to serialize, move across a network (with no compression and no protocol overheads) and deserialize a given dataset.

|Dataset\Measure|transfer [10 MBits]|transfer [100 MBits]|transfer [1000 MBits]|
| ---| ---| ---| ---|
| ---| ---| ---| ---|
|BinTree Direction|[flat](https://hackage.haskell.org/package/flat)|[flat](https://hackage.haskell.org/package/flat),[store](https://hackage.haskell.org/package/store)|[store](https://hackage.haskell.org/package/store),[flat](https://hackage.haskell.org/package/flat)|
|BinTree Int|[flat](https://hackage.haskell.org/package/flat)|[flat](https://hackage.haskell.org/package/flat)|[store](https://hackage.haskell.org/package/store),[flat](https://hackage.haskell.org/package/flat)|
|Cars|[flat](https://hackage.haskell.org/package/flat)|[flat](https://hackage.haskell.org/package/flat)|[store](https://hackage.haskell.org/package/store),[flat](https://hackage.haskell.org/package/flat)|
Expand All @@ -25,7 +25,7 @@ Tests are executed on an Intel Xeon W3520 @ 2.67GHz. On a slower machine, de(ser
### (De)serialization Times and Size

|Dataset\Measure|deserialization|serialization|size|
| ---| ---| ---| ---|
| ---| ---| ---| ---|
|BinTree Direction|[flat](https://hackage.haskell.org/package/flat),[store](https://hackage.haskell.org/package/store)|[store](https://hackage.haskell.org/package/store)|[flat](https://hackage.haskell.org/package/flat)|
|BinTree Int|[store](https://hackage.haskell.org/package/store),[flat](https://hackage.haskell.org/package/flat),[cereal](https://hackage.haskell.org/package/cereal)|[store](https://hackage.haskell.org/package/store)|[flat](https://hackage.haskell.org/package/flat)|
|Cars|[flat](https://hackage.haskell.org/package/flat),[store](https://hackage.haskell.org/package/store)|[store](https://hackage.haskell.org/package/store)|[flat](https://hackage.haskell.org/package/flat)|
Expand All @@ -48,12 +48,13 @@ Performance is not the only relevant property, depending on your needs you shoul

| Package | Laziness | Compatibility |
| --- | --- | --- |
| [store-0.5.0](https://hackage.haskell.org/package/store) | Strict | Haskell-Same-Architecture |
| [store-0.5.0](https://hackage.haskell.org/package/store) | Strict | Haskell-Same-Architecture |
| [packman-0.5.0](http://hackage.haskell.org/package/packman) | Lazy | Haskell-Same-Architecture |
| [cereal-0.5.7.0](http://hackage.haskell.org/package/cereal) | Strict | Haskell |
| [binary-0.8.5.1](http://hackage.haskell.org/package/binary) | Lazy | Haskell |
| [serialise-0.2.0.0](https://hackage.haskell.org/package/serialise) | Lazy | Multi-Language |
| [flat-0.3.2](https://hackage.haskell.org/package/flat) | Strict | Multi-Language |
| [flat-0.3.2](https://hackage.haskell.org/package/flat) | Strict | Multi-Language |
| [persist-0.1](https://hackage.haskell.org/package/persist) | Strict | Haskell |

Compatibility Levels (lowest to highest):
* Haskell-Same-Architecture
Expand Down
2 changes: 2 additions & 0 deletions serialization.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ library
criterion >= 1.4.1.0,
serialise,
cereal,
persist,
binary,
flat,
packman,
Expand Down Expand Up @@ -52,6 +53,7 @@ benchmark all
criterion >= 1.4.1.0,
serialise,
cereal,
persist,
binary,
flat,
packman,
Expand Down
8 changes: 8 additions & 0 deletions src/Dataset.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import qualified Data.Binary as B
import Codec.Serialise as CBOR
import qualified Data.Flat as F
import qualified Data.Serialize as C
import qualified Data.Persist as R
import qualified Data.Store as S
import Numeric.Datasets (getDataset)
-- import Numeric.Datasets.Abalone (abalone)
Expand All @@ -20,27 +21,31 @@ instance C.Serialize RelScore
instance CBOR.Serialise RelScore
instance F.Flat RelScore
instance S.Store RelScore
instance R.Persist RelScore

instance NFData RelSize
instance B.Binary RelSize
instance C.Serialize RelSize
instance CBOR.Serialise RelSize
instance F.Flat RelSize
instance S.Store RelSize
instance R.Persist RelSize

instance NFData Acceptability
instance B.Binary Acceptability
instance C.Serialize Acceptability
instance CBOR.Serialise Acceptability
instance F.Flat Acceptability
instance S.Store Acceptability
instance R.Persist Acceptability

instance NFData Count
instance B.Binary Count
instance C.Serialize Count
instance CBOR.Serialise Count
instance F.Flat Count
instance S.Store Count
instance R.Persist Count

deriving instance Eq Car
instance NFData Car
Expand All @@ -49,6 +54,7 @@ instance C.Serialize Car
instance CBOR.Serialise Car
instance F.Flat Car
instance S.Store Car
instance R.Persist Car

deriving instance Eq Iris
instance NFData Iris
Expand All @@ -57,13 +63,15 @@ instance C.Serialize Iris
instance CBOR.Serialise Iris
instance F.Flat Iris
instance S.Store Iris
instance R.Persist Iris

instance NFData IrisClass
instance B.Binary IrisClass
instance C.Serialize IrisClass
instance CBOR.Serialise IrisClass
instance F.Flat IrisClass
instance S.Store IrisClass
instance R.Persist IrisClass

-- irisData = iris
irisData :: [Iris]
Expand Down
19 changes: 18 additions & 1 deletion src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import System.Mem (performMajorGC)
-- import Data.Binary.Serialise.CBOR.Encoding as CBOR
import qualified Data.Flat as F
import qualified Data.Serialize as C
import qualified Data.Persist as R
import qualified Data.Store as S
import Dataset
import qualified GHC.Packing as P
Expand Down Expand Up @@ -69,6 +70,8 @@ instance {-# OVERLAPPABLE #-} B.Binary a => B.Binary (BinTree a)

instance {-# OVERLAPPABLE #-} C.Serialize a => C.Serialize (BinTree a)

instance {-# OVERLAPPABLE #-} R.Persist a => R.Persist (BinTree a)

instance {-# OVERLAPPABLE #-} CBOR.Serialise a =>
CBOR.Serialise (BinTree a)

Expand Down Expand Up @@ -115,6 +118,7 @@ data Direction
, C.Serialize
, CBOR.Serialise
, S.Store
, R.Persist
, F.Flat
)

Expand Down Expand Up @@ -163,6 +167,9 @@ instance Arbitrary Direction where
data PkgBinary =
PkgBinary

data PkgPersist =
PkgPersist

data PkgCereal =
PkgCereal

Expand All @@ -188,6 +195,12 @@ instance (B.Binary a, NFData a) => Serialize PkgBinary a where
{-# NOINLINE deserialize #-}
deserialize _ = return . force . B.decode . LBS.fromStrict

instance (R.Persist a, NFData a) => Serialize PkgPersist a where
{-# NOINLINE serialize #-}
serialize _ = return . force . R.encode
{-# NOINLINE deserialize #-}
deserialize _ = either error (return . force) . R.decode

instance (C.Serialize a, NFData a) => Serialize PkgCereal a where
{-# NOINLINE serialize #-}
serialize _ = return . force . C.encode
Expand Down Expand Up @@ -225,6 +238,7 @@ pkgs ::
, C.Serialize a
, Typeable a
, Serialise a
, R.Persist a
, S.Store a
, F.Flat a
, B.Binary a
Expand All @@ -235,6 +249,7 @@ pkgs =
, ("store", serialize PkgStore, deserialize PkgStore)
, ("binary", serialize PkgBinary, deserialize PkgBinary)
, ("cereal", serialize PkgCereal, deserialize PkgCereal)
, ("persist", serialize PkgPersist, deserialize PkgPersist)
, ("packman", serialize PkgPackman, deserialize PkgPackman)
, ("serialise", serialize PkgCBOR, deserialize PkgCBOR)
]
Expand Down Expand Up @@ -315,6 +330,7 @@ sizes ::
, B.Binary t
, F.Flat t
, Serialise t
, R.Persist t
, C.Serialize t
, S.Store t
)
Expand All @@ -335,6 +351,7 @@ benchs ::
, B.Binary a
, F.Flat a
, Serialise a
, R.Persist a
, C.Serialize a
, S.Store a
)
Expand All @@ -361,7 +378,7 @@ main
-- runQC CBOR
= do
runBench
-- print $ S.encode [North, South] -- "\STX\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SOH"
-- print $ S.encode [North, South] -- "\STX\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SOH"
-- -- "\STX\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SOH"

fromRight :: Either a b -> b
Expand Down
1 change: 1 addition & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ flags:

extra-deps:
- flat-0.3.2
- persist-0.1
- packman-0.5.0
# - binary-0.8.5.1
- cereal-0.5.7.0
Expand Down

0 comments on commit d269776

Please sign in to comment.