forked from IntersectMBO/cardano-node
-
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.
Merge pull request IntersectMBO#5048 from input-output-hk/nyc-plutus-…
…bench-01 use TH-generated plutus scripts
- Loading branch information
Showing
14 changed files
with
121 additions
and
59 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
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
42 changes: 42 additions & 0 deletions
42
bench/plutus-scripts-bench/src/Cardano/Benchmarking/ScriptAPI.hs
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,42 @@ | ||
{-# OPTIONS_GHC -fno-warn-orphans #-} | ||
|
||
module Cardano.Benchmarking.ScriptAPI | ||
( PlutusBenchScript | ||
, psName | ||
, psScript | ||
, mkPlutusBenchScript | ||
, prepareScriptName | ||
) where | ||
|
||
import Prelude as Haskell (String, ($)) | ||
import Data.Char (isUpper) | ||
import Data.Maybe (fromMaybe) | ||
import System.FilePath (splitExtension, stripExtension, takeFileName) | ||
import Cardano.Api (ScriptInAnyLang) | ||
|
||
data PlutusBenchScript | ||
= PlutusBenchScript | ||
{ psName :: String | ||
, psScript :: ScriptInAnyLang | ||
} | ||
|
||
mkPlutusBenchScript :: String -> ScriptInAnyLang -> PlutusBenchScript | ||
mkPlutusBenchScript = PlutusBenchScript | ||
|
||
-- This is doing two or three sorts of normalisation at once: | ||
-- It strips leading / -separated components, drops the ".hs" suffix | ||
-- if present, then chooses the last . -separated component. | ||
-- If there is a suffix different from .hs that begins with a capital | ||
-- letter, that is returned. | ||
-- e.g. "Data/List/System.FilePath.Text.hs" --> "Text" | ||
-- "Data/List/System.FilePath.Text" --> "Text" | ||
prepareScriptName :: String -> String | ||
prepareScriptName script | ||
= case splitExtension file' of | ||
(s, "") -> s -- no dots so take it as-is | ||
(_, '.':s@(c:_)) | isUpper c -> s -- take last dot-separated component | ||
_ -> file' -- shouldn't happen | ||
where | ||
file = takeFileName script -- ignore leading directories | ||
-- no trailing .hs so use filename as-is | ||
file' = fromMaybe file $ stripExtension "hs" file |
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
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.