-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into rsoeldner/nix-cache
- Loading branch information
Showing
103 changed files
with
6,660 additions
and
2,966 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
{-# LANGUAGE CPP #-} | ||
{-# LANGUAGE DeriveFoldable #-} | ||
{-# LANGUAGE DeriveFunctor #-} | ||
{-# LANGUAGE DeriveTraversable #-} | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE StandaloneDeriving #-} | ||
|
||
{-# OPTIONS_GHC -Wno-orphans #-} | ||
|
||
-- | | ||
-- Module: PactJson | ||
-- Copyright: Copyright © 2023 Kadena LLC. | ||
-- License: MIT | ||
-- Maintainer: Lars Kuhtz <[email protected]> | ||
-- Stability: experimental | ||
-- | ||
-- benchmarks for pact-json | ||
-- | ||
module Main | ||
( main | ||
) where | ||
|
||
import Bound | ||
|
||
import Criterion | ||
import Criterion.Main | ||
|
||
import qualified Data.Aeson as A | ||
import qualified Data.ByteString.Lazy as BL | ||
|
||
import qualified Pact.JSON.Encode as J | ||
|
||
import System.IO.Unsafe | ||
|
||
import Test.QuickCheck | ||
|
||
-- internal modules | ||
import Pact.Types.Command | ||
import Pact.Types.Names | ||
import Pact.Types.RowData | ||
import Pact.Types.SPV | ||
import Pact.Types.Term | ||
import Pact.Types.Term.Arbitrary () | ||
|
||
|
||
-- -------------------------------------------------------------------------- -- | ||
-- Main | ||
|
||
main :: IO () | ||
main = defaultMain [benchmarks] | ||
|
||
-- -------------------------------------------------------------------------- -- | ||
-- Benchmarks | ||
|
||
benchmarks :: Benchmark | ||
benchmarks = bgroup "JsonEncoding" | ||
[ bgroup "pact" | ||
[ group "module" pactModule | ||
, group "RowData" rowData | ||
, group "CommandResult" commandResult | ||
, group "ContProof" contProof | ||
] | ||
] | ||
|
||
group | ||
:: J.Encode a | ||
=> String | ||
-> a | ||
-> Benchmark | ||
group l a = bgroup l | ||
[ bench_encode a | ||
] | ||
|
||
-- -------------------------------------------------------------------------- -- | ||
-- Benchmark Functions | ||
|
||
bench_encode :: J.Encode a => a -> Benchmark | ||
bench_encode a = bench "bench_encode" $ nf run_encode a | ||
|
||
run_encode :: J.Encode a => a -> BL.ByteString | ||
run_encode = J.encode | ||
{-# NOINLINE run_encode #-} | ||
|
||
-- -------------------------------------------------------------------------- -- | ||
-- Orphans | ||
|
||
deriving newtype instance A.ToJSON a => A.ToJSON (J.Aeson a) | ||
deriving newtype instance A.FromJSON a => A.FromJSON (J.Aeson a) | ||
deriving newtype instance Show a => Show (J.Aeson a) | ||
deriving newtype instance Eq a => Eq (J.Aeson a) | ||
deriving newtype instance Arbitrary a => Arbitrary (J.Aeson a) | ||
deriving instance Functor J.Aeson | ||
deriving instance Foldable J.Aeson | ||
deriving instance Traversable J.Aeson | ||
|
||
instance J.Encode [J.Aeson ()] where | ||
build a = J.build $ J.Array a | ||
|
||
instance J.Encode [Var Int [J.Aeson ()]] where | ||
build a = J.build $ J.Array a | ||
|
||
-- -------------------------------------------------------------------------- -- | ||
-- Benchmark Data | ||
-- | ||
|
||
type A = J.Aeson | ||
|
||
pactModule :: Module Name | ||
pactModule = unsafeDupablePerformIO $ generate $ arbitrary | ||
{-# NOINLINE pactModule #-} | ||
|
||
rowData :: RowData | ||
rowData = unsafeDupablePerformIO $ generate $ arbitrary | ||
{-# NOINLINE rowData #-} | ||
|
||
commandResult :: CommandResult (A ()) | ||
commandResult = unsafeDupablePerformIO $ generate $ arbitrary | ||
{-# NOINLINE commandResult #-} | ||
|
||
contProof :: ContProof | ||
contProof = unsafeDupablePerformIO $ generate $ arbitrary | ||
{-# NOINLINE contProof #-} | ||
|
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,18 +1,55 @@ | ||
packages: . | ||
|
||
allow-older: libBF:hashable | ||
|
||
-- temporary upper bounds | ||
constraints: sbv <10 | ||
|
||
-- these upper bounds are required in order to not break payload validation in chainweb | ||
constraints: aeson <2 | ||
constraints: base16-bytestring <1 | ||
constraints: base64-bytestring <1.1 | ||
constraints: hashable <1.3.1 | ||
constraints: prettyprinter <1.6.1 | ||
constraints: unordered-containers <0.2.16 | ||
constraints: base64-bytestring <1.1 | ||
|
||
allow-newer: base64-bytestring:* | ||
allow-newer: base16-bytestring:* | ||
allow-newer: prettyprinter:* | ||
|
||
-- test upper bounds | ||
constraints: hspec-golden <0.2, | ||
|
||
-- The following fork provides trifecta-2.`1.1.1 which is compatible with | ||
-- hashable >=1.4 and prettyprinter <1.7 | ||
-- | ||
-- trifeta >=2.1.2 requires a prettyprinter >=1.7, which isn't supported by | ||
-- pact (because it would break mainnet replays). trifecta ==2.1.1 does not | ||
-- support hashable >=1.4. | ||
-- | ||
source-repository-package | ||
type: git | ||
tag: f991ffb74a1a1ab86f14e751d7c4f4ba549785b3 | ||
location: https://github.com/hackage-package-forks/trifecta | ||
--sha256: sha256-m+IplwZ9DxJt6Mzkq961BzgiboHJul6w1uwDUqXnljo= | ||
|
||
source-repository-package | ||
type: git | ||
tag: e43073d0b8d89d9b300980913b842f4be339846d | ||
location: https://github.com/kadena-io/pact-json | ||
--sha256: sha256-ZWbAId0JBaxDsYhwcYUyw04sjYstXyosSCenzOvUxsQ= | ||
|
||
-- Required for GHC-9.6 | ||
|
||
allow-newer: *:template-haskell | ||
allow-newer: *:base | ||
|
||
-- Patch merged into master (upcoming verison 10.0). We are currently using 9.2 | ||
source-repository-package | ||
type: git | ||
tag: b66e3a04c20f753213fe7e5115a95b3fe34109f9 | ||
location: https://github.com/larskuhtz/sbv | ||
--sha256: sha256-NQ00KGhu4IWeAry0r6m6FR/iCu/XboWtjOhbU+gtijU= | ||
|
||
-- Servant is notoriously forcing outdated upper bounds onto its users. | ||
-- It is usually safe to just ignore those. | ||
-- | ||
allow-newer: servant-server:* | ||
allow-newer: servant-client-core:* | ||
allow-newer: servant-client:* | ||
allow-newer: servant:* |
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.