Skip to content

Commit

Permalink
Updates to README files
Browse files Browse the repository at this point in the history
  • Loading branch information
kwxm committed Oct 22, 2020
1 parent 14d18f8 commit 715fad2
Show file tree
Hide file tree
Showing 95 changed files with 73 additions and 44 deletions.
50 changes: 50 additions & 0 deletions plutus-benchmark/README.md
@@ -0,0 +1,50 @@
## Plutus Benchmarks

This directory contains two sets of benchmarks:

* `nofib`: Plutus versions of some of Haskell's `nofib` benchmarks from https://github.com/ghc/nofib.

* The source for the individual programs is in `nofib/src`
* There is an executable in `nofib/exe` which can be used to run the individual programs (compiled into Plutus)
* The benchmarking code is in `nofib/bench`.

* To run the benchmarks using stack, type a command like this
* `stack bench plutus-benchmark:nofib` (run all benchmarks; this will take a long time)
* `stack bench plutus-benchmark:nofib --ba "clausify/formula2 -L300"` (run the `clausify/formula2`
benchmark with a time limit of 300 seconds)

* The corresponding cabal commands are
* `cabal v2-bench plutus-benchmark:nofib`
* `cabal v2-bench plutus-benchmark:nofib --benchmark-options "clausify/formula2 -L300"``

* `validation`: a number of Plutus Core scripts extracted from the `plutus-use-cases` tests which represent realistic on-chain
transaction validations.

* The scripts are stored as Plutus Core source in `validation/data`, along with a description
of how to combine them to obtain executable applied validators.
* Benchmarking code is stored in `validation/Main.hs`.

* To run the benchmarks using stack, type a command like this
* `stack bench plutus-benchmark:validation` (run all benchmarks)
* `stack bench plutus-benchmark:validation --ba "crowdfunding/2 -L10"` (run the `crowdfunding/2`
benchmark with a time limit of 10 seconds)
* The corresponding cabal commands are
* `cabal v2-bench plutus-benchmark:validation`
* `cabal v2-bench plutus-benchmark:validation --benchmark-options "crowdfunding/2 -L10"`

See also [nofib/README.md](./nofib/README.md) and [validation/README.md.](./validation/README.md.).

### Criterion output

Both sets of benchmarks will generate a file called `report.html` containing
detailed information about the results of running the benchmarks. This will be
written to the `plutus-benchmarks` directory. To put it elsewhere, pass
Criterion the `--output` option along with an *absolute* path (relative paths
are interpreted relative to `plutus-benchmarks` when running the benchmarks via
satck or cabal): for example

```
stack bench plutus-benchmark:validation --ba "crowdfunding -L10 --output $PWD/crowdfunding-report.html"
```

The `templates` directory contains some template files for use by Criterion.
Expand Up @@ -72,14 +72,19 @@ main = defaultMainWith config [
, bench "formula4" $ benchClausify Clausify.F4
, bench "formula5" $ benchClausify Clausify.F5
]
, bgroup "knights" [ -- Knight's tour on an NxN board; no solutions for N odd or N=4
bench "4x4" $ benchKnights 150 4
, bench "6x6" $ benchKnights 150 6
, bench "8x8" $ benchKnights 150 8
]
, bgroup "primetest" [ bench "05digits" $ benchPrime Prime.P5
, bench "08digits" $ benchPrime Prime.P8
, bench "10digits" $ benchPrime Prime.P10
, bench "20digits" $ benchPrime Prime.P20
, bench "30digits" $ benchPrime Prime.P30
, bench "40digits" $ benchPrime Prime.P40
, bench "50digits" $ benchPrime Prime.P50
, bench "60digits" $ benchPrime Prime.P60
-- , bench "50digits" $ benchPrime Prime.P50
-- , bench "60digits" $ benchPrime Prime.P60
]
, bgroup "queens4x4" [ -- N-queens problem on a 4x4 board
bench "bt" $ benchQueens 4 Queens.Bt
Expand All @@ -95,9 +100,4 @@ main = defaultMainWith config [
, bench "bjbt2" $ benchQueens 5 Queens.Bjbt2
, bench "fc" $ benchQueens 5 Queens.Fc
]
, bgroup "knights" [ -- Knight's tour on an NxN board; no solutions for N odd or N=4
bench "4x4" $ benchKnights 150 4
, bench "6x6" $ benchKnights 150 6
, bench "8x8" $ benchKnights 150 8
]
]
Expand Up @@ -67,8 +67,8 @@ knightsOptions =
queensAlgorithmReader :: String -> Either String Queens.Algorithm
queensAlgorithmReader "bt" = Right Queens.Bt
queensAlgorithmReader "bm" = Right Queens.Bm
queensAlgorithmReader "bjbt" = Right Queens.Bjbt
queensAlgorithmReader "bjbt1" = Right Queens.Bjbt1
queensAlgorithmReader "bjbt2" = Right Queens.Bjbt2
queensAlgorithmReader "fc" = Right Queens.Fc
queensAlgorithmReader alg = Left $ "Unknown algorithm: " <> alg <> ". I know of: bt, bm, bjbt, bjbt1 or fc."

Expand Down
Expand Up @@ -242,30 +242,6 @@ getPrime =
P50 -> 22953686867719691230002707821868552601124472329079
P60 -> 511704374946917490638851104912462284144240813125071454126151

{- Some large primes and the time and space required to check them.
56123
81241579
9576890767 -- 10 digits: 2.4s, 0.9 GB
40206835204840513073 -- 20 digits: 4.7s, 1.8 GB
115756986668303657898962467957 -- 30 digits: 7.3s, 3.3 GB
671998030559713968361666935769 -- 30 digits: 7.5s, 3.3 GB
4125636888562548868221559797461449 -- 34 digits: 7.5s, 3.2 GB
5991810554633396517767024967580894321153 -- 40 digits: 11s, 5.2 GB
22953686867719691230002707821868552601124472329079 -- 50 digits: 10s, 4.6 GB
48705091355238882778842909230056712140813460157899 -- 50 digits: 10.8s, 4.7 GB
511704374946917490638851104912462284144240813125071454126151 -- 60 digits: 15s, 7.5 GB
7595009151080016652449223792726748985452052945413160073645842090827711 -- 70 digits: 16s, 7.7 GB (swapping on an 8GB machine)
40979218404449071854385509743772465043384063785613460568705289173181846900181503 -- 80 digits: process killed by OS.
23785274372342411111117777171111111111111111711111111111111111111111111111111111111111111111111111111111111
533791764536500962982816454877600313815808544134584704665367971790938714376754987723404131641943766815146845004667377003395107827504566198008424339207
-- ^ 150 digits: far too big for the CEK machine, 40s and 94 MB on the CK machine.
58021664585639791181184025950440248398226136069516938232493687505822471836536824298822733710342250697739996825938232641940670857624514103125986134050997697160127301547995788468137887651823707102007839
-- ^ 200 digits. 55s and 97 MB on the CK machine.
8987964267331664557 -- Composite: 61ms, 68 MB
-}

-- % Only for textual output of PLC scripts
unindent :: PLC.Doc ann -> [Prelude.String]
Expand Down
24 changes: 12 additions & 12 deletions plutus-benchmark/plutus-benchmark.cabal
Expand Up @@ -14,12 +14,12 @@ description:
build-type: Simple

data-files:
bench-validation/data/crowdfunding/*.plc
bench-validation/data/future/*.plc
bench-validation/data/multisigSM/*.plc
bench-validation/data/vesting/*.plc
bench-validation/data/marlowe/trustfund/*.plc
bench-validation/data/marlowe/zerocoupon/*.plc
validation/data/crowdfunding/*.plc
validation/data/future/*.plc
validation/data/multisigSM/*.plc
validation/data/vesting/*.plc
validation/data/marlowe/trustfund/*.plc
validation/data/marlowe/zerocoupon/*.plc
templates/*.tpl

source-repository head
Expand Down Expand Up @@ -50,7 +50,7 @@ library
Plutus.Benchmark.LastPiece
Plutus.Benchmark.Prime
hs-source-dirs:
src
nofib/src
build-depends:
base >=4.7 && <5
, plutus-tx -any
Expand All @@ -67,11 +67,11 @@ library
other-extensions:
NoImplicitPrelude

executable plutus-benchmark
executable nofib-exe
import: lang
main-is: Main.hs
hs-source-dirs:
app
nofib/exe
build-depends:
base >=4.7 && <5
, plutus-benchmark
Expand All @@ -81,12 +81,12 @@ executable plutus-benchmark
, containers -any
, optparse-applicative -any

benchmark large-plc-cek
benchmark nofib
import: lang
type: exitcode-stdio-1.0
main-is: Main.hs
hs-source-dirs:
bench
nofib/bench
build-depends:
base >=4.7 && <5
, plutus-benchmark
Expand All @@ -102,7 +102,7 @@ benchmark validation
type: exitcode-stdio-1.0
main-is: Main.hs
hs-source-dirs:
bench-validation
validation
other-modules:
Paths_plutus_benchmark
build-depends:
Expand Down
3 changes: 3 additions & 0 deletions plutus-benchmark/templates/README.md
@@ -0,0 +1,3 @@
Criterion templates for use by benchmarking code. `with-iterations.tpl` is used
to produce an extended version of Criterion's HTML report which includes the
total number of runs of each benchmark and the total execution time.
File renamed without changes.
File renamed without changes.

0 comments on commit 715fad2

Please sign in to comment.