Skip to content

Commit 20a1dd3

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 9c5a6ae + 3592da3 commit 20a1dd3

File tree

6 files changed

+35
-5
lines changed

6 files changed

+35
-5
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
dist
22
.cabal-sandbox/
3+
.stack-work
34
cabal.sandbox.config

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The summary tables list, for every test, all libraries that are within 30% of th
1111
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.
1212

1313
|Dataset\Measure|transfer [10 MBits]|transfer [100 MBits]|transfer [1000 MBits]|
14-
| ---| ---| ---| ---|
14+
| ---| ---| ---| ---|
1515
|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)|
1616
|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)|
1717
|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)|
@@ -25,7 +25,7 @@ Tests are executed on an Intel Xeon W3520 @ 2.67GHz. On a slower machine, de(ser
2525
### (De)serialization Times and Size
2626

2727
|Dataset\Measure|deserialization|serialization|size|
28-
| ---| ---| ---| ---|
28+
| ---| ---| ---| ---|
2929
|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)|
3030
|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)|
3131
|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)|
@@ -48,12 +48,13 @@ Performance is not the only relevant property, depending on your needs you shoul
4848

4949
| Package | Laziness | Compatibility |
5050
| --- | --- | --- |
51-
| [store-0.5.0](https://hackage.haskell.org/package/store) | Strict | Haskell-Same-Architecture |
51+
| [store-0.5.0](https://hackage.haskell.org/package/store) | Strict | Haskell-Same-Architecture |
5252
| [packman-0.5.0](http://hackage.haskell.org/package/packman) | Lazy | Haskell-Same-Architecture |
5353
| [cereal-0.5.7.0](http://hackage.haskell.org/package/cereal) | Strict | Haskell |
5454
| [binary-0.8.5.1](http://hackage.haskell.org/package/binary) | Lazy | Haskell |
5555
| [serialise-0.2.0.0](https://hackage.haskell.org/package/serialise) | Lazy | Multi-Language |
56-
| [flat-0.3.2](https://hackage.haskell.org/package/flat) | Strict | Multi-Language |
56+
| [flat-0.3.2](https://hackage.haskell.org/package/flat) | Strict | Multi-Language |
57+
| [persist-0.1](https://hackage.haskell.org/package/persist) | Strict | Haskell |
5758

5859
Compatibility Levels (lowest to highest):
5960
* Haskell-Same-Architecture

serialization.cabal

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ library
2121
criterion >= 1.4.1.0,
2222
serialise,
2323
cereal,
24+
persist,
2425
binary,
2526
flat,
2627
packman,
@@ -53,6 +54,7 @@ benchmark all
5354
text,
5455
serialise,
5556
cereal,
57+
persist,
5658
binary,
5759
flat,
5860
packman,

src/Dataset.hs

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import qualified Data.Binary as B
88
import Codec.Serialise as CBOR
99
import qualified Data.Flat as F
1010
import qualified Data.Serialize as C
11+
import qualified Data.Persist as R
1112
import qualified Data.Store as S
1213
import Numeric.Datasets (getDataset)
1314
-- import Numeric.Datasets.Abalone (abalone)
@@ -20,27 +21,31 @@ instance C.Serialize RelScore
2021
instance CBOR.Serialise RelScore
2122
instance F.Flat RelScore
2223
instance S.Store RelScore
24+
instance R.Persist RelScore
2325

2426
instance NFData RelSize
2527
instance B.Binary RelSize
2628
instance C.Serialize RelSize
2729
instance CBOR.Serialise RelSize
2830
instance F.Flat RelSize
2931
instance S.Store RelSize
32+
instance R.Persist RelSize
3033

3134
instance NFData Acceptability
3235
instance B.Binary Acceptability
3336
instance C.Serialize Acceptability
3437
instance CBOR.Serialise Acceptability
3538
instance F.Flat Acceptability
3639
instance S.Store Acceptability
40+
instance R.Persist Acceptability
3741

3842
instance NFData Count
3943
instance B.Binary Count
4044
instance C.Serialize Count
4145
instance CBOR.Serialise Count
4246
instance F.Flat Count
4347
instance S.Store Count
48+
instance R.Persist Count
4449

4550
deriving instance Eq Car
4651
instance NFData Car
@@ -49,6 +54,7 @@ instance C.Serialize Car
4954
instance CBOR.Serialise Car
5055
instance F.Flat Car
5156
instance S.Store Car
57+
instance R.Persist Car
5258

5359
deriving instance Eq Iris
5460
instance NFData Iris
@@ -57,13 +63,15 @@ instance C.Serialize Iris
5763
instance CBOR.Serialise Iris
5864
instance F.Flat Iris
5965
instance S.Store Iris
66+
instance R.Persist Iris
6067

6168
instance NFData IrisClass
6269
instance B.Binary IrisClass
6370
instance C.Serialize IrisClass
6471
instance CBOR.Serialise IrisClass
6572
instance F.Flat IrisClass
6673
instance S.Store IrisClass
74+
instance R.Persist IrisClass
6775

6876
-- irisData = iris
6977
irisData :: [Iris]

src/Main.hs

+18-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import GHC.Generics
2525
import System.Mem (performMajorGC)
2626
import qualified Data.Flat as F
2727
import qualified Data.Serialize as C
28+
import qualified Data.Persist as R
2829
import qualified Data.Store as S
2930
import Dataset
3031
import qualified GHC.Packing as P
@@ -52,6 +53,8 @@ instance {-# OVERLAPPABLE #-} B.Binary a => B.Binary (BinTree a)
5253

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

56+
instance {-# OVERLAPPABLE #-} R.Persist a => R.Persist (BinTree a)
57+
5558
instance {-# OVERLAPPABLE #-} CBOR.Serialise a =>
5659
CBOR.Serialise (BinTree a)
5760

@@ -102,6 +105,7 @@ data Direction
102105
, C.Serialize
103106
, CBOR.Serialise
104107
, S.Store
108+
, R.Persist
105109
, F.Flat
106110
)
107111

@@ -150,6 +154,9 @@ instance Arbitrary Direction where
150154
data PkgBinary =
151155
PkgBinary
152156

157+
data PkgPersist =
158+
PkgPersist
159+
153160
data PkgCereal =
154161
PkgCereal
155162

@@ -178,6 +185,12 @@ instance (B.Binary a, NFData a) => Serialize PkgBinary a where
178185
{-# NOINLINE deserialize #-}
179186
deserialize _ = return . force . B.decode . LBS.fromStrict
180187

188+
instance (R.Persist a, NFData a) => Serialize PkgPersist a where
189+
{-# NOINLINE serialize #-}
190+
serialize _ = return . force . R.encode
191+
{-# NOINLINE deserialize #-}
192+
deserialize _ = either error (return . force) . R.decode
193+
181194
instance (C.Serialize a, NFData a) => Serialize PkgCereal a where
182195
{-# NOINLINE serialize #-}
183196
serialize _ = return . force . C.encode
@@ -221,6 +234,7 @@ pkgs ::
221234
, C.Serialize a
222235
, Typeable a
223236
, Serialise a
237+
, R.Persist a
224238
, S.Store a
225239
, F.Flat a
226240
, B.Binary a
@@ -237,6 +251,7 @@ pkgs =
237251
, ("store", serialize PkgStore, deserialize PkgStore)
238252
, ("binary", serialize PkgBinary, deserialize PkgBinary)
239253
, ("cereal", serialize PkgCereal, deserialize PkgCereal)
254+
, ("persist", serialize PkgPersist, deserialize PkgPersist)
240255
, ("packman", serialize PkgPackman, deserialize PkgPackman)
241256
, ("serialise", serialize PkgCBOR, deserialize PkgCBOR)
242257
, ("show", serialize PkgShow, deserialize PkgShow)
@@ -324,6 +339,7 @@ sizes ::
324339
, B.Binary t
325340
, F.Flat t
326341
, Serialise t
342+
, R.Persist t
327343
, C.Serialize t
328344
, S.Store t,Show t, Read t
329345
)
@@ -344,6 +360,7 @@ benchs ::
344360
, B.Binary a
345361
, F.Flat a
346362
, Serialise a
363+
, R.Persist a
347364
, C.Serialize a
348365
, S.Store a,Read a,Show a
349366
)
@@ -370,7 +387,7 @@ main
370387
-- runQC CBOR
371388
= do
372389
runBench
373-
-- print $ S.encode [North, South] -- "\STX\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SOH"
390+
-- print $ S.encode [North, South] -- "\STX\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SOH"
374391
-- -- "\STX\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SOH"
375392

376393
fromRight :: Either a b -> b

stack.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ flags:
1919

2020
extra-deps:
2121
- flat-0.3.2
22+
- persist-0.1
2223
- packman-0.5.0
2324
# - binary-0.8.5.1
2425
- cereal-0.5.7.0

0 commit comments

Comments
 (0)