Skip to content

Commit a17a0e8

Browse files
authored
Merge pull request #604 from Lysxia/aeson-compare-auto-instances
Add benchmarks for derived instances
2 parents f701f73 + d45d504 commit a17a0e8

File tree

12 files changed

+347
-285
lines changed

12 files changed

+347
-285
lines changed

benchmarks/AesonCompareAutoInstances.hs

Lines changed: 0 additions & 282 deletions
This file was deleted.

benchmarks/Auto/G/BigProduct.hs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{-# LANGUAGE DeriveGeneric #-}
2+
3+
module Auto.G.BigProduct where
4+
5+
import Control.DeepSeq
6+
import Data.Aeson
7+
import GHC.Generics (Generic)
8+
import Options
9+
10+
data BigProduct = BigProduct
11+
!Int !Int !Int !Int !Int
12+
!Int !Int !Int !Int !Int
13+
!Int !Int !Int !Int !Int
14+
!Int !Int !Int !Int !Int
15+
!Int !Int !Int !Int !Int
16+
deriving (Show, Eq, Generic)
17+
18+
instance NFData BigProduct where
19+
rnf a = a `seq` ()
20+
21+
instance ToJSON BigProduct where
22+
toJSON = genericToJSON opts
23+
toEncoding = genericToEncoding opts
24+
25+
instance FromJSON BigProduct where
26+
parseJSON = genericParseJSON opts
27+
28+
bigProduct :: BigProduct
29+
bigProduct = BigProduct 1 2 3 4 5
30+
6 7 8 9 10
31+
11 12 13 14 15
32+
16 17 18 19 20
33+
21 22 23 24 25

benchmarks/Auto/G/BigRecord.hs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{-# LANGUAGE DeriveGeneric #-}
2+
3+
module Auto.G.BigRecord where
4+
5+
import Control.DeepSeq
6+
import Data.Aeson
7+
import GHC.Generics (Generic)
8+
import Options
9+
10+
data BigRecord = BigRecord
11+
{ field01 :: !Int, field02 :: !Int, field03 :: !Int, field04 :: !Int, field05 :: !Int
12+
, field06 :: !Int, field07 :: !Int, field08 :: !Int, field09 :: !Int, field10 :: !Int
13+
, field11 :: !Int, field12 :: !Int, field13 :: !Int, field14 :: !Int, field15 :: !Int
14+
, field16 :: !Int, field17 :: !Int, field18 :: !Int, field19 :: !Int, field20 :: !Int
15+
, field21 :: !Int, field22 :: !Int, field23 :: !Int, field24 :: !Int, field25 :: !Int
16+
} deriving (Show, Eq, Generic)
17+
18+
instance NFData BigRecord where
19+
rnf a = a `seq` ()
20+
21+
instance ToJSON BigRecord where
22+
toJSON = genericToJSON opts
23+
toEncoding = genericToEncoding opts
24+
25+
instance FromJSON BigRecord where
26+
parseJSON = genericParseJSON opts
27+
28+
bigRecord :: BigRecord
29+
bigRecord = BigRecord 1 2 3 4 5
30+
6 7 8 9 10
31+
11 12 13 14 15
32+
16 17 18 19 20
33+
21 22 23 24 25

benchmarks/Auto/G/BigSum.hs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{-# LANGUAGE DeriveGeneric #-}
2+
3+
module Auto.G.BigSum where
4+
5+
import Control.DeepSeq
6+
import Data.Aeson
7+
import GHC.Generics (Generic)
8+
import Options
9+
10+
data BigSum = F01 | F02 | F03 | F04 | F05
11+
| F06 | F07 | F08 | F09 | F10
12+
| F11 | F12 | F13 | F14 | F15
13+
| F16 | F17 | F18 | F19 | F20
14+
| F21 | F22 | F23 | F24 | F25
15+
deriving (Show, Eq, Generic)
16+
17+
instance NFData BigSum where
18+
rnf a = a `seq` ()
19+
20+
instance ToJSON BigSum where
21+
toJSON = genericToJSON opts
22+
toEncoding = genericToEncoding opts
23+
24+
instance FromJSON BigSum where
25+
parseJSON = genericParseJSON opts
26+
27+
bigSum :: BigSum
28+
bigSum = F25

0 commit comments

Comments
 (0)