on master help sign in
Merge pull request #563 from phadej/benchmarks-fix-562
6306cecAdam Bergmark
.gitignore+1
@@ -4,6 +4,7 @@ dist-newstyle
4.cabal-sandbox/
4.cabal-sandbox/
5cabal.sandbox.config
5cabal.sandbox.config
6.stack-work/
6.stack-work/
7+.stack-work-bench/
7
8
8*.o
9*.o
9*.hi
10*.hi
benchmarks/AesonMap.hs+6−6
@@ -160,7 +160,7 @@ benchDecodeHM name val = bgroup name
160 , bench "Identity" $ nf (decodeHMB proxyT1) val
160 , bench "Identity" $ nf (decodeHMB proxyT1) val
161 , bench "Coerce" $ nf (decodeHMB proxyT2) val
161 , bench "Coerce" $ nf (decodeHMB proxyT2) val
162 , bench "Parser" $ nf (decodeHMB proxyT3) val
162 , bench "Parser" $ nf (decodeHMB proxyT3) val
163− , bench "aeson-0.11" $ nf (decodeHMA proxyText) val
163+ , bench "aeson-hackage" $ nf (decodeHMA proxyText) val
164 , bench "Tagged Text" $ nf (decodeHMB $ proxyTagged proxyText) val
164 , bench "Tagged Text" $ nf (decodeHMB $ proxyTagged proxyText) val
165 , bench "Tagged Identity" $ nf (decodeHMB $ proxyTagged proxyT1) val
165 , bench "Tagged Identity" $ nf (decodeHMB $ proxyTagged proxyT1) val
166 , bench "Tagged Coerce" $ nf (decodeHMB $ proxyTagged proxyT2) val
166 , bench "Tagged Coerce" $ nf (decodeHMB $ proxyTagged proxyT2) val
@@ -172,11 +172,11 @@ benchDecodeMap
172 -> LBS.ByteString
172 -> LBS.ByteString
173 -> Benchmark
173 -> Benchmark
174benchDecodeMap name val = bgroup name
174benchDecodeMap name val = bgroup name
175− [ bench "Text" $ nf (decodeMapB proxyText) val
175+ [ bench "Text" $ nf (decodeMapB proxyText) val
176− , bench "Identity" $ nf (decodeMapB proxyT1) val
176+ , bench "Identity" $ nf (decodeMapB proxyT1) val
177− , bench "Coerce" $ nf (decodeMapB proxyT2) val
177+ , bench "Coerce" $ nf (decodeMapB proxyT2) val
178− , bench "Parser" $ nf (decodeMapB proxyT3) val
178+ , bench "Parser" $ nf (decodeMapB proxyT3) val
179− , bench "aeson-0.11" $ nf (decodeMapA proxyText) val
179+ , bench "aeson-hackage" $ nf (decodeMapA proxyText) val
180 ]
180 ]
181
181
182benchEncodeHM
182benchEncodeHM
benchmarks/CompareWithJSON.hs+32−7
@@ -1,3 +1,4 @@
1+{-# LANGUAGE PackageImports #-}
1{-# OPTIONS_GHC -fno-warn-orphans #-}
2{-# OPTIONS_GHC -fno-warn-orphans #-}
2
3
3module Main (main) where
4module Main (main) where
@@ -10,8 +11,11 @@ import Blaze.ByteString.Builder.Char.Utf8 (fromString)
10import Control.DeepSeq (NFData(rnf))
11import Control.DeepSeq (NFData(rnf))
11import Criterion.Main
12import Criterion.Main
12import Data.Maybe (fromMaybe)
13import Data.Maybe (fromMaybe)
13−import qualified Data.Aeson as A
14+import qualified "aeson-benchmarks" Data.Aeson as A
14−import qualified Data.Aeson.Text as A
15+import qualified "aeson-benchmarks" Data.Aeson.Text as A
16+import qualified "aeson-benchmarks" Data.Aeson.Parser.Internal as I
17+import qualified "aeson" Data.Aeson as B
18+import qualified Data.ByteString as BS
15import qualified Data.ByteString.Lazy as BL
19import qualified Data.ByteString.Lazy as BL
16import qualified Data.Text.Lazy as TL
20import qualified Data.Text.Lazy as TL
17import qualified Data.Text.Lazy.Builder as TLB
21import qualified Data.Text.Lazy.Builder as TLB
@@ -41,6 +45,19 @@ decodeA s = fromMaybe (error "fail to parse via Aeson") $ A.decode s
41decodeA' :: BL.ByteString -> A.Value
45decodeA' :: BL.ByteString -> A.Value
42decodeA' s = fromMaybe (error "fail to parse via Aeson") $ A.decode' s
46decodeA' s = fromMaybe (error "fail to parse via Aeson") $ A.decode' s
43
47
48+decodeAS :: BS.ByteString -> A.Value
49+decodeAS s = fromMaybe (error "fail to parse via Aeson") $ A.decodeStrict' s
50+
51+decodeB :: BL.ByteString -> B.Value
52+decodeB s = fromMaybe (error "fail to parse via Aeson") $ B.decode s
53+
54+decodeBS :: BS.ByteString -> B.Value
55+decodeBS s = fromMaybe (error "fail to parse via Aeson") $ B.decodeStrict' s
56+
57+decodeIP :: BL.ByteString -> A.Value
58+decodeIP s = fromMaybe (error "fail to parse via Parser.decodeWith") $
59+ I.decodeWith I.jsonEOF A.fromJSON s
60+
44encodeJ :: J.JSValue -> BL.ByteString
61encodeJ :: J.JSValue -> BL.ByteString
45encodeJ = toLazyByteString . fromString . J.encode
62encodeJ = toLazyByteString . fromString . J.encode
46
63
@@ -55,19 +72,27 @@ main = do
55 let enFile = "json-data/twitter100.json"
72 let enFile = "json-data/twitter100.json"
56 jpFile = "json-data/jp100.json"
73 jpFile = "json-data/jp100.json"
57 enA <- BL.readFile enFile
74 enA <- BL.readFile enFile
75+ enS <- BS.readFile enFile
58 enJ <- readFile enFile
76 enJ <- readFile enFile
59 jpA <- BL.readFile jpFile
77 jpA <- BL.readFile jpFile
78+ jpS <- BS.readFile jpFile
60 jpJ <- readFile jpFile
79 jpJ <- readFile jpFile
61 defaultMain [
80 defaultMain [
62 bgroup "decode" [
81 bgroup "decode" [
63 bgroup "en" [
82 bgroup "en" [
64− bench "aeson/lazy" $ nf decodeA enA
83+ bench "aeson/lazy" $ nf decodeA enA
65− , bench "aeson/strict" $ nf decodeA' enA
84+ , bench "aeson/strict" $ nf decodeA' enA
85+ , bench "aeson/stricter" $ nf decodeAS enS
86+ , bench "aeson/hackage" $ nf decodeB enA
87+ , bench "aeson/hackage'" $ nf decodeBS enS
88+ , bench "aeson/parser" $ nf decodeIP enA
66− , bench "json" $ nf decodeJ enJ
89+ , bench "json" $ nf decodeJ enJ
67 ]
90 ]
68 , bgroup "jp" [
91 , bgroup "jp" [
69− bench "aeson" $ nf decodeA jpA
92+ bench "aeson" $ nf decodeA jpA
93+ , bench "aeson/stricter" $ nf decodeAS jpS
94+ , bench "aeson/hackage" $ nf decodeB jpA
70− , bench "json" $ nf decodeJ jpJ
95+ , bench "json" $ nf decodeJ jpJ
71 ]
96 ]
72 ]
97 ]
73 , bgroup "encode" [
98 , bgroup "encode" [
benchmarks/Dates.hs+1
@@ -1,3 +1,4 @@
1+{-# OPTIONS_GHC -fsimpl-tick-factor=0 #-}
1module Main (main) where
2module Main (main) where
2
3
3import Prelude ()
4import Prelude ()
benchmarks/Typed.hs+3
@@ -13,4 +13,7 @@ main = defaultMain [
13 Generic.benchmarks
13 Generic.benchmarks
14 , Manual.benchmarks
14 , Manual.benchmarks
15 , TH.benchmarks
15 , TH.benchmarks
16+ , Generic.decodeBenchmarks
17+ , Manual.decodeBenchmarks
18+ , TH.decodeBenchmarks
16 ]
19 ]
benchmarks/Typed/Generic.hs+21−3
@@ -1,5 +1,5 @@
1{-# LANGUAGE PackageImports #-}
1{-# LANGUAGE PackageImports #-}
2−module Typed.Generic (benchmarks) where
2+module Typed.Generic (benchmarks, decodeBenchmarks) where
3
3
4import Prelude ()
4import Prelude ()
5import Prelude.Compat
5import Prelude.Compat
@@ -7,7 +7,7 @@ import Prelude.Compat
7import "aeson" Data.Aeson hiding (Result)
7import "aeson" Data.Aeson hiding (Result)
8import Criterion
8import Criterion
9import Data.ByteString.Lazy as L
9import Data.ByteString.Lazy as L
10−import Twitter.TH
10+import Twitter.Generic
11import Typed.Common
11import Typed.Common
12import qualified "aeson-benchmarks" Data.Aeson as B
12import qualified "aeson-benchmarks" Data.Aeson as B
13
13
@@ -26,7 +26,7 @@ encodeViaValueB = B.encode . B.toJSON
26benchmarks :: Benchmark
26benchmarks :: Benchmark
27benchmarks =
27benchmarks =
28 env ((,) <$> load "json-data/twitter100.json" <*> load "json-data/jp100.json") $ \ ~(twitter100, jp100) ->
28 env ((,) <$> load "json-data/twitter100.json" <*> load "json-data/jp100.json") $ \ ~(twitter100, jp100) ->
29− bgroup "generic" [
29+ bgroup "encodeGeneric" [
30 bgroup "direct" [
30 bgroup "direct" [
31 bench "twitter100" $ nf encodeDirectB twitter100
31 bench "twitter100" $ nf encodeDirectB twitter100
32 , bench "jp100" $ nf encodeDirectB jp100
32 , bench "jp100" $ nf encodeDirectB jp100
@@ -40,3 +40,21 @@ benchmarks =
40 , bench "jp100 baseline" $ nf encodeViaValueA jp100
40 , bench "jp100 baseline" $ nf encodeViaValueA jp100
41 ]
41 ]
42 ]
42 ]
43+
44+decodeDirectA :: L.ByteString -> Maybe Result
45+decodeDirectA = decode
46+
47+decodeDirectB :: L.ByteString -> Maybe Result
48+decodeDirectB = B.decode
49+
50+decodeBenchmarks :: Benchmark
51+decodeBenchmarks =
52+ env ((,) <$> L.readFile "json-data/twitter100.json" <*> L.readFile "json-data/jp100.json") $ \ ~(twitter100, jp100) ->
53+ bgroup "decodeGeneric"
54+ [ bgroup "direct"
55+ [ bench "twitter100" $ nf decodeDirectB twitter100
56+ , bench "jp100" $ nf decodeDirectB jp100
57+ , bench "twitter100 baseline" $ nf decodeDirectA twitter100
58+ , bench "jp100 baseline" $ nf decodeDirectA jp100
59+ ]
60+ ]
benchmarks/Typed/Manual.hs+20−2
@@ -1,5 +1,5 @@
1{-# LANGUAGE PackageImports #-}
1{-# LANGUAGE PackageImports #-}
2−module Typed.Manual (benchmarks) where
2+module Typed.Manual (benchmarks, decodeBenchmarks) where
3
3
4import Prelude ()
4import Prelude ()
5import Prelude.Compat
5import Prelude.Compat
@@ -26,7 +26,7 @@ encodeViaValueB = B.encode . B.toJSON
26benchmarks :: Benchmark
26benchmarks :: Benchmark
27benchmarks =
27benchmarks =
28 env ((,) <$> load "json-data/twitter100.json" <*> load "json-data/jp100.json") $ \ ~(twitter100, jp100) ->
28 env ((,) <$> load "json-data/twitter100.json" <*> load "json-data/jp100.json") $ \ ~(twitter100, jp100) ->
29− bgroup "manual" [
29+ bgroup "encodeManual" [
30 bgroup "direct" [
30 bgroup "direct" [
31 bench "twitter100" $ nf encodeDirectB twitter100
31 bench "twitter100" $ nf encodeDirectB twitter100
32 , bench "jp100" $ nf encodeDirectB jp100
32 , bench "jp100" $ nf encodeDirectB jp100
@@ -40,3 +40,21 @@ benchmarks =
40 , bench "jp100 baseline" $ nf encodeViaValueA jp100
40 , bench "jp100 baseline" $ nf encodeViaValueA jp100
41 ]
41 ]
42 ]
42 ]
43+
44+decodeDirectA :: L.ByteString -> Maybe Result
45+decodeDirectA = decode
46+
47+decodeDirectB :: L.ByteString -> Maybe Result
48+decodeDirectB = B.decode
49+
50+decodeBenchmarks :: Benchmark
51+decodeBenchmarks =
52+ env ((,) <$> L.readFile "json-data/twitter100.json" <*> L.readFile "json-data/jp100.json") $ \ ~(twitter100, jp100) ->
53+ bgroup "decodeManual"
54+ [ bgroup "direct"
55+ [ bench "twitter100" $ nf decodeDirectB twitter100
56+ , bench "jp100" $ nf decodeDirectB jp100
57+ , bench "twitter100 baseline" $ nf decodeDirectA twitter100
58+ , bench "jp100 baseline" $ nf decodeDirectA jp100
59+ ]
60+ ]
benchmarks/Typed/TH.hs+20−2
@@ -1,5 +1,5 @@
1{-# LANGUAGE PackageImports #-}
1{-# LANGUAGE PackageImports #-}
2−module Typed.TH (benchmarks) where
2+module Typed.TH (benchmarks, decodeBenchmarks) where
3
3
4import Prelude ()
4import Prelude ()
5import Prelude.Compat
5import Prelude.Compat
@@ -26,7 +26,7 @@ encodeViaValueB = B.encode . B.toJSON
26benchmarks :: Benchmark
26benchmarks :: Benchmark
27benchmarks =
27benchmarks =
28 env ((,) <$> load "json-data/twitter100.json" <*> load "json-data/jp100.json") $ \ ~(twitter100, jp100) ->
28 env ((,) <$> load "json-data/twitter100.json" <*> load "json-data/jp100.json") $ \ ~(twitter100, jp100) ->
29− bgroup "th" [
29+ bgroup "encodeTH" [
30 bgroup "direct" [
30 bgroup "direct" [
31 bench "twitter100" $ nf encodeDirectB twitter100
31 bench "twitter100" $ nf encodeDirectB twitter100
32 , bench "jp100" $ nf encodeDirectB jp100
32 , bench "jp100" $ nf encodeDirectB jp100
@@ -40,3 +40,21 @@ benchmarks =
40 , bench "jp100 baseline" $ nf encodeViaValueB jp100
40 , bench "jp100 baseline" $ nf encodeViaValueB jp100
41 ]
41 ]
42 ]
42 ]
43+
44+decodeDirectA :: L.ByteString -> Maybe Result
45+decodeDirectA = decode
46+
47+decodeDirectB :: L.ByteString -> Maybe Result
48+decodeDirectB = B.decode
49+
50+decodeBenchmarks :: Benchmark
51+decodeBenchmarks =
52+ env ((,) <$> L.readFile "json-data/twitter100.json" <*> L.readFile "json-data/jp100.json") $ \ ~(twitter100, jp100) ->
53+ bgroup "decodeTH"
54+ [ bgroup "direct"
55+ [ bench "twitter100" $ nf decodeDirectB twitter100
56+ , bench "jp100" $ nf decodeDirectB jp100
57+ , bench "twitter100 baseline" $ nf decodeDirectA twitter100
58+ , bench "jp100 baseline" $ nf decodeDirectA jp100
59+ ]
60+ ]
benchmarks/aeson-benchmarks.cabal+19
@@ -83,6 +83,13 @@ executable aeson-benchmark-compare
83 main-is: Compare.hs
83 main-is: Compare.hs
84 hs-source-dirs: ../examples .
84 hs-source-dirs: ../examples .
85 ghc-options: -Wall -O2 -rtsopts
85 ghc-options: -Wall -O2 -rtsopts
86+ other-modules:
87+ Compare.BufferBuilder
88+ Compare.JsonBench
89+ Compare.JsonBuilder
90+ Twitter
91+ Twitter.Manual
92+ Typed.Common
86 build-depends:
93 build-depends:
87 aeson-benchmarks,
94 aeson-benchmarks,
88 base,
95 base,
@@ -116,6 +123,16 @@ executable aeson-benchmark-typed
116 -- We must help ourself in situations when there is both
123 -- We must help ourself in situations when there is both
117 -- aeson and aeson-benchmakrs
124 -- aeson and aeson-benchmakrs
118 cpp-options: -DHAS_BOTH_AESON_AND_BENCHMARKS
125 cpp-options: -DHAS_BOTH_AESON_AND_BENCHMARKS
126+ other-modules:
127+ Twitter
128+ Twitter.Generic
129+ Twitter.Manual
130+ Twitter.Options
131+ Twitter.TH
132+ Typed.Common
133+ Typed.Generic
134+ Typed.Manual
135+ Typed.TH
119 build-depends:
136 build-depends:
120 aeson,
137 aeson,
121 aeson-benchmarks,
138 aeson-benchmarks,
@@ -136,7 +153,9 @@ executable aeson-benchmark-typed
136executable aeson-benchmark-compare-with-json
153executable aeson-benchmark-compare-with-json
137 main-is: CompareWithJSON.hs
154 main-is: CompareWithJSON.hs
138 ghc-options: -Wall -O2 -rtsopts
155 ghc-options: -Wall -O2 -rtsopts
156+ cpp-options: -DHAS_BOTH_AESON_AND_BENCHMARKS
139 build-depends:
157 build-depends:
158+ aeson,
140 aeson-benchmarks,
159 aeson-benchmarks,
141 base,
160 base,
142 base-compat,
161 base-compat,
examples/Twitter/Generic.hs+49−19
@@ -1,7 +1,12 @@
1-- Use GHC generics to automatically generate good instances.
1-- Use GHC generics to automatically generate good instances.
2+
2{-# LANGUAGE CPP #-}
3{-# LANGUAGE CPP #-}
3{-# OPTIONS_GHC -fno-warn-orphans #-}
4{-# OPTIONS_GHC -fno-warn-orphans #-}
4
5
6+#ifdef HAS_BOTH_AESON_AND_BENCHMARKS
7+{-# LANGUAGE PackageImports #-}
8+#endif
9+
5module Twitter.Generic
10module Twitter.Generic
6 (
11 (
7 Metadata(..)
12 Metadata(..)
@@ -11,39 +16,64 @@ module Twitter.Generic
11 ) where
16 ) where
12
17
13import Prelude ()
18import Prelude ()
14−import Prelude.Compat
19+import Prelude.Compat ()
15
20
16import Twitter
21import Twitter
22+import Twitter.Options
17
23
18#ifndef HAS_BOTH_AESON_AND_BENCHMARKS
24#ifndef HAS_BOTH_AESON_AND_BENCHMARKS
19−import Data.Aeson (ToJSON, FromJSON)
25+import Data.Aeson (ToJSON (..), FromJSON (..), genericToJSON, genericToEncoding, genericParseJSON)
20#else
26#else
21−import "aeson" Data.Aeson (ToJSON, FromJSON)
27+import "aeson" Data.Aeson (ToJSON (..), FromJSON (..), genericToJSON, genericToEncoding, genericParseJSON)
22import qualified "aeson-benchmarks" Data.Aeson as B
28import qualified "aeson-benchmarks" Data.Aeson as B
23#endif
29#endif
24
30
25−instance ToJSON Metadata
31+instance ToJSON Metadata where
32+ toJSON = genericToJSON twitterOptions
33+ toEncoding = genericToEncoding twitterOptions
26−instance FromJSON Metadata
34+instance FromJSON Metadata where
35+ parseJSON = genericParseJSON twitterOptions
27
36
28−instance ToJSON Geo
37+instance ToJSON Geo where
38+ toJSON = genericToJSON twitterOptions
39+ toEncoding = genericToEncoding twitterOptions
29−instance FromJSON Geo
40+instance FromJSON Geo where
41+ parseJSON = genericParseJSON twitterOptions
30
42
31−instance ToJSON Story
43+instance ToJSON Story where
44+ toJSON = genericToJSON twitterOptions
45+ toEncoding = genericToEncoding twitterOptions
32−instance FromJSON Story
46+instance FromJSON Story where
47+ parseJSON = genericParseJSON twitterOptions
33
48
34−instance ToJSON Result
49+instance ToJSON Result where
50+ toJSON = genericToJSON twitterOptions
51+ toEncoding = genericToEncoding twitterOptions
35−instance FromJSON Result
52+instance FromJSON Result where
53+ parseJSON = genericParseJSON twitterOptions
36
54
37#ifdef HAS_BOTH_AESON_AND_BENCHMARKS
55#ifdef HAS_BOTH_AESON_AND_BENCHMARKS
38−instance B.ToJSON Metadata
56+instance B.ToJSON Metadata where
57+ toJSON = B.genericToJSON btwitterOptions
58+ toEncoding = B.genericToEncoding btwitterOptions
39−instance B.FromJSON Metadata
59+instance B.FromJSON Metadata where
60+ parseJSON = B.genericParseJSON btwitterOptions
40
61
41−instance B.ToJSON Geo
62+instance B.ToJSON Geo where
63+ toJSON = B.genericToJSON btwitterOptions
64+ toEncoding = B.genericToEncoding btwitterOptions
42−instance B.FromJSON Geo
65+instance B.FromJSON Geo where
66+ parseJSON = B.genericParseJSON btwitterOptions
43
67
44−instance B.ToJSON Story
68+instance B.ToJSON Story where
69+ toJSON = B.genericToJSON btwitterOptions
70+ toEncoding = B.genericToEncoding btwitterOptions
45−instance B.FromJSON Story
71+instance B.FromJSON Story where
72+ parseJSON = B.genericParseJSON btwitterOptions
46
73
47−instance B.ToJSON Result
74+instance B.ToJSON Result where
75+ toJSON = B.genericToJSON btwitterOptions
76+ toEncoding = B.genericToEncoding btwitterOptions
48−instance B.FromJSON Result
77+instance B.FromJSON Result where
78+ parseJSON = B.genericParseJSON btwitterOptions
49#endif
79#endif
examples/Twitter/Options.hsnew file+33
@@ -0,0 +1,33 @@
1+{-# LANGUAGE CPP #-}
2+
3+#ifdef HAS_BOTH_AESON_AND_BENCHMARKS
4+{-# LANGUAGE PackageImports #-}
5+#endif
6+
7+module Twitter.Options (module Twitter.Options) where
8+
9+#ifndef HAS_BOTH_AESON_AND_BENCHMARKS
10+import Data.Aeson
11+import Data.Aeson.Types
12+#else
13+import "aeson" Data.Aeson
14+import "aeson" Data.Aeson.Types
15+import qualified "aeson-benchmarks" Data.Aeson as B
16+import qualified "aeson-benchmarks" Data.Aeson.Types as B
17+#endif
18+
19+twitterOptions :: Options
20+twitterOptions = defaultOptions
21+ { fieldLabelModifier = \x -> case x of
22+ "id_" -> "id"
23+ _ -> x
24+ }
25+
26+#ifdef HAS_BOTH_AESON_AND_BENCHMARKS
27+btwitterOptions :: B.Options
28+btwitterOptions = B.defaultOptions
29+ { B.fieldLabelModifier = \x -> case x of
30+ "id_" -> "id"
31+ _ -> x
32+ }
33+#endif
examples/Twitter/TH.hs+13−9
@@ -1,10 +1,13 @@
1-- Use Template Haskell to generate good instances.
1-- Use Template Haskell to generate good instances.
2
2
3{-# LANGUAGE CPP #-}
3{-# LANGUAGE CPP #-}
4−{-# LANGUAGE PackageImports #-}
5{-# LANGUAGE TemplateHaskell #-}
4{-# LANGUAGE TemplateHaskell #-}
6{-# OPTIONS_GHC -fno-warn-orphans #-}
5{-# OPTIONS_GHC -fno-warn-orphans #-}
7
6
7+#ifdef HAS_BOTH_AESON_AND_BENCHMARKS
8+{-# LANGUAGE PackageImports #-}
9+#endif
10+
8module Twitter.TH
11module Twitter.TH
9 (
12 (
10 Metadata(..)
13 Metadata(..)
@@ -16,6 +19,7 @@ module Twitter.TH
16import Prelude ()
19import Prelude ()
17
20
18import Twitter
21import Twitter
22+import Twitter.Options
19
23
20#ifndef HAS_BOTH_AESON_AND_BENCHMARKS
24#ifndef HAS_BOTH_AESON_AND_BENCHMARKS
21import Data.Aeson.TH
25import Data.Aeson.TH
@@ -24,14 +28,14 @@ import "aeson" Data.Aeson.TH
24import qualified "aeson-benchmarks" Data.Aeson.TH as B
28import qualified "aeson-benchmarks" Data.Aeson.TH as B
25#endif
29#endif
26
30
27−$(deriveJSON defaultOptions ''Metadata)
31+$(deriveJSON twitterOptions ''Metadata)
28−$(deriveJSON defaultOptions ''Geo)
32+$(deriveJSON twitterOptions ''Geo)
29−$(deriveJSON defaultOptions ''Story)
33+$(deriveJSON twitterOptions ''Story)
30−$(deriveJSON defaultOptions ''Result)
34+$(deriveJSON twitterOptions ''Result)
31
35
32#ifdef HAS_BOTH_AESON_AND_BENCHMARKS
36#ifdef HAS_BOTH_AESON_AND_BENCHMARKS
33−$(B.deriveJSON B.defaultOptions ''Metadata)
37+$(B.deriveJSON btwitterOptions ''Metadata)
34−$(B.deriveJSON B.defaultOptions ''Geo)
38+$(B.deriveJSON btwitterOptions ''Geo)
35−$(B.deriveJSON B.defaultOptions ''Story)
39+$(B.deriveJSON btwitterOptions ''Story)
36−$(B.deriveJSON B.defaultOptions ''Result)
40+$(B.deriveJSON btwitterOptions ''Result)
37#endif
41#endif
stack-bench.yaml+9−1
@@ -1,7 +1,15 @@
1resolver: lts-8.5
1resolver: lts-8.5
2+# We use aeson in the snapshot to
3+# - avoid recompilation of criterion
4+# - compare against it
5+# - '.'
6+#
7+# Also we use separate working directory to avoid "unregistering aeson"
8+# caused recompilations
9+work-dir: .stack-work-bench
2packages:
10packages:
3−- '.'
4- benchmarks
11- benchmarks
5extra-deps:
12extra-deps:
13+- aeson-1.2.1.0
6- quickcheck-instances-0.3.14
14- quickcheck-instances-0.3.14
7- th-abstraction-0.2.2.0
15- th-abstraction-0.2.2.0