Build Haskell benchmarks with cabal
commit17013ccd02c46c153210b9f0ab84689527f89c65
authorBryan O'Sullivan <bos@serpentine.com>
dateThu 22 Dec 2011, 08:54 (15 years ago)
parenta42161d
.hgignore+1−1
@@ -1,6 +1,6 @@
11.*\.(?:aux|h[ip]|o|orig|out|pdf|prof|ps|rej)$
22^(?:dist|\.DS_Store)$
3−^benchmarks/(?:AesonParse|AesonEncode|JsonParse|.*_p)$
3+^benchmarks/dist$
44^tests/(?:qc)
55
66syntax: glob
aeson.cabal+1
@@ -84,6 +84,7 @@ description:
8484
8585extra-source-files:
8686 README.markdown
87+ benchmarks/*.cabal
8788 benchmarks/*.hs
8889 benchmarks/*.py
8990 benchmarks/Makefile
benchmarks/AesonEncode.hs−2
@@ -3,8 +3,6 @@
33import Control.Exception
44import Control.Monad
55import Data.Aeson
6−import Data.Aeson.Encode
7−import Data.Aeson.Parser
86import Data.Attoparsec
97import Data.Time.Clock
108import System.Environment (getArgs)
benchmarks/AesonParse.hs−2
@@ -1,10 +1,8 @@
11{-# LANGUAGE BangPatterns, OverloadedStrings #-}
22
3−import Control.DeepSeq
43import Control.Exception
54import Control.Monad
65import Data.Aeson
7−import Data.Aeson.Parser
86import Data.Attoparsec
97import Data.Time.Clock
108import System.Environment (getArgs)
benchmarks/CompareWithJSON.hs+2−2
@@ -36,7 +36,7 @@ decodeA s = case A.decode' s of
3636 Just v -> v
3737
3838jsonData :: FilePath
39−jsonData = "benchmarks/json-data/jp100.json"
39+jsonData = "json-data/jp100.json"
4040
4141main :: IO ()
4242main = do
@@ -44,7 +44,7 @@ main = do
4444 as <- BL.readFile jsonData
4545 let jdata = decodeJ js
4646 adata = decodeA as
47− (jdata, adata) `deepseq` defaultMain [
47+ defaultMain [
4848 bgroup "decode" [ bench "json" $ nf decodeJ js
4949 , bench "aeson" $ nf decodeA as
5050 ],
benchmarks/JsonParse.hs+1−2
@@ -1,13 +1,12 @@
11{-# LANGUAGE BangPatterns, ScopedTypeVariables #-}
2+{-# OPTIONS_GHC -fno-warn-orphans #-}
23
34import Control.DeepSeq
4−import Control.Exception
55import Control.Monad
66import Text.JSON
77import Data.Time.Clock
88import System.Environment (getArgs)
99import System.IO
10−import qualified Data.ByteString as B
1110
1211instance NFData JSValue where
1312 rnf JSNull = ()
benchmarks/aeson-benchmarks.cabalnew file+39
@@ -0,0 +1,39 @@
1+name: aeson-benchmarks
2+version: 0
3+build-type: Simple
4+
5+cabal-version: >=1.2
6+
7+executable aeson-benchmark-compare-with-json
8+ main-is: CompareWithJSON.hs
9+ ghc-options: -Wall -O2
10+ build-depends:
11+ aeson == 0.4.0.0,
12+ base,
13+ bytestring,
14+ criterion,
15+ json
16+
17+executable aeson-benchmark-aeson-encode
18+ main-is: AesonEncode.hs
19+ ghc-options: -Wall -O2
20+ build-depends:
21+ aeson == 0.4.0.0,
22+ base
23+
24+executable aeson-benchmark-aeson-parse
25+ main-is: AesonParse.hs
26+ ghc-options: -Wall -O2
27+ build-depends:
28+ aeson == 0.4.0.0,
29+ attoparsec,
30+ base
31+
32+executable aeson-benchmark-json-parse
33+ main-is: JsonParse.hs
34+ ghc-options: -Wall -O2
35+ build-depends:
36+ base,
37+ deepseq,
38+ json,
39+ time