Commits

Bryan O'Sullivan committed 7db0788

Build Haskell benchmarks with cabal

  • Participants
  • Parent commits f9043a8

Comments (0)

Files changed (7)

 .*\.(?:aux|h[ip]|o|orig|out|pdf|prof|ps|rej)$
 ^(?:dist|\.DS_Store)$
-^benchmarks/(?:AesonParse|AesonEncode|JsonParse|.*_p)$
+^benchmarks/dist$
 ^tests/(?:qc)
 
 syntax: glob
 
 extra-source-files:
     README.markdown
+    benchmarks/*.cabal
     benchmarks/*.hs
     benchmarks/*.py
     benchmarks/Makefile

benchmarks/AesonEncode.hs

 import Control.Exception
 import Control.Monad
 import Data.Aeson
-import Data.Aeson.Encode
-import Data.Aeson.Parser
 import Data.Attoparsec
 import Data.Time.Clock
 import System.Environment (getArgs)

benchmarks/AesonParse.hs

 {-# LANGUAGE BangPatterns, OverloadedStrings #-}
 
-import Control.DeepSeq
 import Control.Exception
 import Control.Monad
 import Data.Aeson
-import Data.Aeson.Parser
 import Data.Attoparsec
 import Data.Time.Clock
 import System.Environment (getArgs)

benchmarks/CompareWithJSON.hs

               Just v -> v
 
 jsonData :: FilePath
-jsonData = "benchmarks/json-data/jp100.json"
+jsonData = "json-data/jp100.json"
 
 main :: IO ()
 main = do
   as <- BL.readFile jsonData
   let jdata = decodeJ js
       adata = decodeA as
-  (jdata, adata) `deepseq` defaultMain [
+  defaultMain [
         bgroup "decode" [ bench "json"  $ nf decodeJ js
                         , bench "aeson" $ nf decodeA as
                         ],

benchmarks/JsonParse.hs

 {-# LANGUAGE BangPatterns, ScopedTypeVariables #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
 
 import Control.DeepSeq
-import Control.Exception
 import Control.Monad
 import Text.JSON
 import Data.Time.Clock
 import System.Environment (getArgs)
 import System.IO
-import qualified Data.ByteString as B
 
 instance NFData JSValue where
     rnf JSNull = ()

benchmarks/aeson-benchmarks.cabal

+name:                aeson-benchmarks
+version:             0
+build-type:          Simple
+
+cabal-version:       >=1.2
+
+executable aeson-benchmark-compare-with-json
+  main-is: CompareWithJSON.hs
+  ghc-options: -Wall -O2
+  build-depends:
+    aeson == 0.4.0.0,
+    base,
+    bytestring,
+    criterion,
+    json
+
+executable aeson-benchmark-aeson-encode
+  main-is: AesonEncode.hs
+  ghc-options: -Wall -O2
+  build-depends:
+    aeson == 0.4.0.0,
+    base
+
+executable aeson-benchmark-aeson-parse
+  main-is: AesonParse.hs
+  ghc-options: -Wall -O2
+  build-depends:
+    aeson == 0.4.0.0,
+    attoparsec,
+    base
+
+executable aeson-benchmark-json-parse
+  main-is: JsonParse.hs
+  ghc-options: -Wall -O2
+  build-depends:
+    base,
+    deepseq,
+    json,
+    time