diff --git a/agora.cabal b/agora.cabal index 2047e69..c26f23b 100644 --- a/agora.cabal +++ b/agora.cabal @@ -130,3 +130,12 @@ test-suite agora-test type: exitcode-stdio-1.0 main-is: Spec.hs hs-source-dirs: test + +benchmark agora-bench + import: lang, deps + hs-source-dirs: bench + main-is: Main.hs + type: exitcode-stdio-1.0 + build-depends: + , plutarch-benchmark + , agora \ No newline at end of file diff --git a/bench.csv b/bench.csv new file mode 100644 index 0000000..c4fe975 --- /dev/null +++ b/bench.csv @@ -0,0 +1,2 @@ +name,cpu,mem,size +full_scripts:authorityTokenPolicy,1280339,4400,284 diff --git a/bench/Main.hs b/bench/Main.hs new file mode 100644 index 0000000..ec50558 --- /dev/null +++ b/bench/Main.hs @@ -0,0 +1,25 @@ +module Main (main) where + +import Prelude + +-------------------------------------------------------------------------------- + +import Plutarch.Benchmark +import Plutus.V1.Ledger.Value qualified as Value + +-------------------------------------------------------------------------------- + +import Agora.AuthorityToken qualified as Agora + +-------------------------------------------------------------------------------- + +main :: IO () +main = do + benchMain benchmarks + +benchmarks :: [NamedBenchmark] +benchmarks = + benchGroup + "full_scripts" + [ bench "authorityTokenPolicy" $ Agora.authorityTokenPolicy (Agora.AuthorityToken (Value.assetClass "" "")) + ] diff --git a/cabal.project b/cabal.project index bd0d96f..ec42141 100644 --- a/cabal.project +++ b/cabal.project @@ -1,3 +1,4 @@ packages: ./. +benchmarks: true tests: true diff --git a/flake.lock b/flake.lock index 60a377d..e68b47a 100644 --- a/flake.lock +++ b/flake.lock @@ -49,6 +49,23 @@ "type": "github" } }, + "autodocodec": { + "flake": false, + "locked": { + "lastModified": 1644358110, + "narHash": "sha256-X1TNZlmO2qDFk3OL4Z1v/gzvd3ouoACAiMweutsYek4=", + "owner": "srid", + "repo": "autodocodec", + "rev": "42b42a7407f33c6c74fa4e8c84906aebfed28daf", + "type": "github" + }, + "original": { + "owner": "srid", + "ref": "ghc921", + "repo": "autodocodec", + "type": "github" + } + }, "cabal-32": { "flake": false, "locked": { @@ -788,6 +805,7 @@ "inputs": { "Shrinker": "Shrinker", "Win32-network": "Win32-network", + "autodocodec": "autodocodec", "cardano-base": "cardano-base", "cardano-crypto": "cardano-crypto", "cardano-prelude": "cardano-prelude", @@ -807,15 +825,18 @@ ], "plutus": "plutus", "protolude": "protolude", + "safe-coloured-text": "safe-coloured-text", "sized-functors": "sized-functors", - "th-extras": "th-extras" + "sydtest": "sydtest", + "th-extras": "th-extras", + "validity": "validity" }, "locked": { - "lastModified": 1644875667, - "narHash": "sha256-eNKEubOfkVGmDX1HbbCTbtIjEyXfxlYedrWuwhOLVrQ=", + "lastModified": 1645006916, + "narHash": "sha256-j8o0D48LfDYqf07bi34474lkFnMZ5TNvcZmACVMw3yA=", "owner": "Plutonomicon", "repo": "plutarch", - "rev": "a0cbe99921aad7c5df9239cb0240933e4d9b2eaa", + "rev": "c77fcd605269bd8183d5496e297eb38503ea0e29", "type": "github" }, "original": { @@ -915,6 +936,23 @@ "plutarch": "plutarch" } }, + "safe-coloured-text": { + "flake": false, + "locked": { + "lastModified": 1644357337, + "narHash": "sha256-sXSKw8m6O9K/H2BBiYqO5e4sJIo+9UP+UvEukRn28d8=", + "owner": "srid", + "repo": "safe-coloured-text", + "rev": "034f3612525568b422e0c62b52417d77b7cf31c2", + "type": "github" + }, + "original": { + "owner": "srid", + "ref": "ghc921", + "repo": "safe-coloured-text", + "type": "github" + } + }, "sized-functors": { "flake": false, "locked": { @@ -980,6 +1018,23 @@ "type": "github" } }, + "sydtest": { + "flake": false, + "locked": { + "lastModified": 1644358460, + "narHash": "sha256-1ZxTLL5YVxktyHqfMywwsNGx5nxNMPXnq33QI6BcvUI=", + "owner": "srid", + "repo": "sydtest", + "rev": "5b572105c30f79c5e20637c6af4eedf39e0ac85a", + "type": "github" + }, + "original": { + "owner": "srid", + "ref": "ghc921", + "repo": "sydtest", + "type": "github" + } + }, "th-extras": { "flake": false, "locked": { @@ -996,6 +1051,23 @@ "rev": "787ed752c1e5d41b5903b74e171ed087de38bffa", "type": "github" } + }, + "validity": { + "flake": false, + "locked": { + "lastModified": 1644358698, + "narHash": "sha256-dpMIu08qXMzy8Kilk/2VWpuwIsfqFtpg/3mkwt5pdjA=", + "owner": "srid", + "repo": "validity", + "rev": "f7982549b95d0ab727950dc876ca06b1862135ba", + "type": "github" + }, + "original": { + "owner": "srid", + "ref": "ghc921", + "repo": "validity", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 0c51115..e574172 100644 --- a/flake.nix +++ b/flake.nix @@ -42,7 +42,7 @@ inherit (plutarch) cabalProjectLocal; extraSources = plutarch.extraSources ++ [{ src = inputs.plutarch; - subdirs = [ "." ]; + subdirs = [ "." "plutarch-benchmark" ]; }]; modules = [ (plutarch.haskellModule system) ]; shell = { @@ -64,7 +64,11 @@ inherit (plutarch) tools; - additional = ps: [ ps.plutarch ps.tasty-quickcheck ]; + additional = ps: [ + ps.plutarch + ps.plutarch-benchmark + ps.tasty-quickcheck + ]; }; }; diff --git a/hie.yaml b/hie.yaml index 23b82b5..bea0b14 100644 --- a/hie.yaml +++ b/hie.yaml @@ -2,5 +2,7 @@ cradle: cabal: - path: "./src" component: "lib:agora" + - path: "./bench" + component: "benchmark:agora-bench" - path: "./test" component: "test:agora-test"