forked from haskell/aeson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make aeson-benchmark-typed compare to old aeson
- Loading branch information
Showing
10 changed files
with
251 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,41 @@ | ||
{-# LANGUAGE PackageImports #-} | ||
module Typed.Generic (benchmarks) where | ||
|
||
import "aeson" Data.Aeson hiding (Result) | ||
import qualified "aeson-benchmarks" Data.Aeson as B | ||
|
||
import Control.Applicative | ||
import Criterion | ||
import Data.Aeson hiding (Result) | ||
import Data.ByteString.Builder as B | ||
import Data.ByteString.Lazy as L | ||
import Twitter.TH | ||
import Typed.Common | ||
|
||
encodeDirect :: Result -> L.ByteString | ||
encodeDirect = encode | ||
encodeDirectA :: Result -> L.ByteString | ||
encodeDirectA = encode | ||
|
||
encodeViaValueA :: Result -> L.ByteString | ||
encodeViaValueA = encode . toJSON | ||
|
||
encodeDirectB :: Result -> L.ByteString | ||
encodeDirectB = B.encode | ||
|
||
encodeViaValue :: Result -> L.ByteString | ||
encodeViaValue = encode . toJSON | ||
encodeViaValueB :: Result -> L.ByteString | ||
encodeViaValueB = B.encode . B.toJSON | ||
|
||
benchmarks :: Benchmark | ||
benchmarks = | ||
env ((,) <$> load "json-data/twitter100.json" <*> load "json-data/jp100.json") $ \ ~(twitter100, jp100) -> | ||
bgroup "generic" [ | ||
bgroup "direct" [ | ||
bench "twitter100" $ nf encodeDirect twitter100 | ||
, bench "jp100" $ nf encodeDirect jp100 | ||
bench "twitter100" $ nf encodeDirectB twitter100 | ||
, bench "jp100" $ nf encodeDirectB jp100 | ||
, bench "twitter100 baseline" $ nf encodeDirectA twitter100 | ||
, bench "jp100 baseline" $ nf encodeDirectA jp100 | ||
] | ||
, bgroup "viaValue" [ | ||
bench "twitter100" $ nf encodeViaValue twitter100 | ||
, bench "jp100" $ nf encodeViaValue jp100 | ||
bench "twitter100" $ nf encodeViaValueB twitter100 | ||
, bench "jp100" $ nf encodeViaValueB jp100 | ||
, bench "twitter100 baseline" $ nf encodeViaValueA twitter100 | ||
, bench "jp100 baseline" $ nf encodeViaValueA jp100 | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,41 @@ | ||
{-# LANGUAGE PackageImports #-} | ||
module Typed.Manual (benchmarks) where | ||
|
||
import "aeson" Data.Aeson hiding (Result) | ||
import qualified "aeson-benchmarks" Data.Aeson as B | ||
|
||
import Control.Applicative | ||
import Criterion | ||
import Data.Aeson hiding (Result) | ||
import Data.ByteString.Builder as B | ||
import Data.ByteString.Lazy as L | ||
import Twitter.Manual | ||
import Typed.Common | ||
|
||
encodeDirect :: Result -> L.ByteString | ||
encodeDirect = encode | ||
encodeDirectA :: Result -> L.ByteString | ||
encodeDirectA = encode | ||
|
||
encodeViaValueA :: Result -> L.ByteString | ||
encodeViaValueA = encode . toJSON | ||
|
||
encodeDirectB :: Result -> L.ByteString | ||
encodeDirectB = B.encode | ||
|
||
encodeViaValue :: Result -> L.ByteString | ||
encodeViaValue = encode . toJSON | ||
encodeViaValueB :: Result -> L.ByteString | ||
encodeViaValueB = B.encode . B.toJSON | ||
|
||
benchmarks :: Benchmark | ||
benchmarks = | ||
env ((,) <$> load "json-data/twitter100.json" <*> load "json-data/jp100.json") $ \ ~(twitter100, jp100) -> | ||
bgroup "manual" [ | ||
bgroup "direct" [ | ||
bench "twitter100" $ nf encodeDirect twitter100 | ||
, bench "jp100" $ nf encodeDirect jp100 | ||
bench "twitter100" $ nf encodeDirectB twitter100 | ||
, bench "jp100" $ nf encodeDirectB jp100 | ||
, bench "twitter100 baseline" $ nf encodeDirectA twitter100 | ||
, bench "jp100 baseline" $ nf encodeDirectA jp100 | ||
] | ||
, bgroup "viaValue" [ | ||
bench "twitter100" $ nf encodeViaValue twitter100 | ||
, bench "jp100" $ nf encodeViaValue jp100 | ||
bench "twitter100" $ nf encodeViaValueB twitter100 | ||
, bench "jp100" $ nf encodeViaValueB jp100 | ||
, bench "twitter100 baseline" $ nf encodeViaValueA twitter100 | ||
, bench "jp100 baseline" $ nf encodeViaValueA jp100 | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,42 @@ | ||
{-# LANGUAGE PackageImports #-} | ||
module Typed.TH (benchmarks) where | ||
|
||
import "aeson" Data.Aeson hiding (Result) | ||
import qualified "aeson-benchmarks" Data.Aeson as B | ||
|
||
import Control.Applicative | ||
import Criterion | ||
import Data.Aeson hiding (Result) | ||
import Data.ByteString.Builder as B | ||
import Data.ByteString.Lazy as L | ||
import Twitter.TH | ||
import Typed.Common | ||
|
||
encodeDirect :: Result -> L.ByteString | ||
encodeDirect = encode | ||
encodeDirectA :: Result -> L.ByteString | ||
encodeDirectA = encode | ||
|
||
encodeViaValueA :: Result -> L.ByteString | ||
encodeViaValueA = encode . toJSON | ||
|
||
encodeDirectB :: Result -> L.ByteString | ||
encodeDirectB = B.encode | ||
|
||
encodeViaValue :: Result -> L.ByteString | ||
encodeViaValue = encode . toJSON | ||
encodeViaValueB :: Result -> L.ByteString | ||
encodeViaValueB = B.encode . B.toJSON | ||
|
||
benchmarks :: Benchmark | ||
benchmarks = | ||
env ((,) <$> load "json-data/twitter100.json" <*> load "json-data/jp100.json") $ \ ~(twitter100, jp100) -> | ||
bgroup "th" [ | ||
bgroup "direct" [ | ||
bench "twitter100" $ nf encodeDirect twitter100 | ||
, bench "jp100" $ nf encodeDirect jp100 | ||
bench "twitter100" $ nf encodeDirectB twitter100 | ||
, bench "jp100" $ nf encodeDirectB jp100 | ||
, bench "twitter100 baseline" $ nf encodeDirectA twitter100 | ||
, bench "jp100 baseline" $ nf encodeDirectA jp100 | ||
] | ||
, bgroup "viaValue" [ | ||
bench "twitter100" $ nf encodeViaValue twitter100 | ||
, bench "jp100" $ nf encodeViaValue jp100 | ||
bench "twitter100" $ nf encodeViaValueA twitter100 | ||
, bench "jp100" $ nf encodeViaValueA jp100 | ||
, bench "twitter100 baseline" $ nf encodeViaValueB twitter100 | ||
, bench "jp100 baseline" $ nf encodeViaValueB jp100 | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.