Skip to content

Commit 9e6a81d

Browse files
authored
Merge pull request #834 from phadej/issue-678-bench
Integrate issue #678 benchmark into suite
2 parents 42d013a + 94e10a1 commit 9e6a81d

File tree

3 files changed

+20
-43
lines changed

3 files changed

+20
-43
lines changed

benchmarks/aeson-benchmarks.cabal

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,14 @@ executable aeson-benchmark-suite
100100
ghc-options: -Wall -O2 -rtsopts
101101
build-depends:
102102
aeson-benchmarks
103+
, attoparsec
103104
, base
104105
, base-compat-batteries
105106
, bytestring
106107
, criterion
107108
, deepseq
108109
, filepath
110+
, scientific
109111
, template-haskell
110112
, text
111113
, time
@@ -115,6 +117,7 @@ executable aeson-benchmark-suite
115117
GitHub
116118
Twitter
117119
Twitter.Manual
120+
Issue673
118121

119122
-- Benchmarks below are haven't been worked out yet
120123

@@ -332,20 +335,3 @@ executable aeson-benchmark-foldable
332335
, text
333336
, unordered-containers
334337
, vector
335-
336-
executable aeson-issue-673
337-
default-language: Haskell2010
338-
main-is: Issue673.hs
339-
hs-source-dirs: bench
340-
ghc-options: -Wall -O1 -rtsopts
341-
build-depends:
342-
aeson-benchmarks
343-
, attoparsec
344-
, base
345-
, base-compat-batteries
346-
, bytestring
347-
, criterion >=1.0
348-
, scientific
349-
350-
if impl(ghc <8.0)
351-
build-depends: semigroups

benchmarks/bench/Issue673.hs

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
{-# LANGUAGE NoImplicitPrelude #-}
22
{-# LANGUAGE OverloadedStrings #-}
33

4-
module Main (
5-
main,
6-
input17,
7-
input32,
8-
input64,
9-
input128,
10-
input256,
11-
input2048,
12-
input4096,
13-
input8192,
14-
input16384,
15-
) where
4+
module Issue673 where
165

176
import Criterion.Main
187
import Prelude.Compat
198
import Data.Int (Int64)
209
import Data.Scientific (Scientific)
21-
import Data.Semigroup ((<>))
2210
import Data.Aeson.Parser (scientific)
2311

2412
import qualified Data.Attoparsec.ByteString.Lazy as AttoL
@@ -87,29 +75,31 @@ input16384 :: LBS.ByteString
8775
input16384 = generate 16384
8876

8977

90-
main :: IO ()
91-
main = defaultMain
78+
benchmark :: Benchmark
79+
benchmark = bgroup "Integer-decoder"
9280
-- works on 64bit
9381
[ benchPair "17" input17
9482
-- , benchPair "32" input32
9583
-- , benchPair "64" input64
9684
-- , benchPair "128" input128
9785
-- , benchPair "256" input256
9886
, benchPair "2048" input2048
99-
, benchPair "4096" input4096
100-
, benchPair "8192" input8192
87+
-- , benchPair "4096" input4096
88+
-- , benchPair "8192" input8192
10189
, benchPair "16384" input16384
10290
]
10391
where
10492
benchPair name input = bgroup name
10593
[ bench "Int" $ whnf decodeInt input
10694
, bench "Simple" $ whnf bsToIntegerSimple (LBS.toStrict input)
107-
, bench "Optim" $ whnf bsToInteger (LBS.toStrict input)
108-
, bench "Read" $ whnf decodeViaRead input
109-
, bench "Scientific" $ whnf decodeScientific input
110-
, bench "parserA" $ whnf decodeAtto input
111-
, bench "parserS" $ whnf decodeAtto8 input
112-
, bench "String" $ whnf decodeString $ "\"" <> input <> "\""
95+
96+
-- other disabled, they are interesting for comparison only.
97+
-- , bench "Optim" $ whnf bsToInteger (LBS.toStrict input)
98+
-- , bench "Read" $ whnf decodeViaRead input
99+
-- , bench "Scientific" $ whnf decodeScientific input
100+
-- , bench "parserA" $ whnf decodeAtto input
101+
-- , bench "parserS" $ whnf decodeAtto8 input
102+
-- , bench "String" $ whnf decodeString $ "\"" <> input <> "\""
113103
]
114104

115105
-------------------------------------------------------------------------------

benchmarks/bench/Suite.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ import qualified Data.Aeson.Encoding.Builder as Aeson.EB
2020
import qualified Data.Aeson.Parser.UnescapeFFI as FFI
2121
import qualified Data.Aeson.Parser.UnescapePure as Pure
2222
import qualified Data.ByteString as BS
23+
import qualified Data.ByteString.Builder as B
2324
import qualified Data.ByteString.Char8 as BS8
2425
import qualified Data.ByteString.Lazy as LBS
2526
import qualified Data.Text as T
26-
import qualified Data.ByteString.Builder as B
2727

28+
import qualified GitHub
29+
import qualified Issue673
2830
import qualified Twitter
2931
import qualified Twitter.Manual ()
3032

31-
import qualified GitHub
32-
3333
-------------------------------------------------------------------------------
3434
-- Decode bench
3535
-------------------------------------------------------------------------------
@@ -104,4 +104,5 @@ main = defaultMain
104104
]
105105
]
106106
, escapeBench
107+
, Issue673.benchmark
107108
]

0 commit comments

Comments
 (0)