Skip to content

Commit bd8d31f

Browse files
committed
tmp
1 parent 20fc454 commit bd8d31f

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

plutus-core/cost-model/budgeting-bench/Benchmarks/Values.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,10 @@ generateConstrainedValue numPolicies tokensPerPolicy g = do
296296
policyIds <- replicateM numPolicies (generateKey g)
297297
tokenNames <- replicateM tokensPerPolicy (generateKey g)
298298

299-
-- Generate positive quantities (1 to 1000000)
300-
let quantity :: Int -> Int -> Integer
301-
quantity policyIndex tokenIndex =
302-
fromIntegral (1 + (policyIndex * 1_000 + tokenIndex) `mod` 1_000_000)
303-
304-
nestedMap :: [(K, [(K, Integer)])]
299+
let nestedMap :: [(K, [(K, Integer)])]
305300
nestedMap =
306301
[ ( policyId
307-
, [ (tokenName, quantity policyIndex tokenIndex)
302+
, [ (tokenName, genQuantity policyIndex tokenIndex)
308303
| (tokenIndex, tokenName) <- zip [0 ..] tokenNames
309304
]
310305
)
@@ -347,3 +342,8 @@ generateKey g = do
347342
-- | Generate random key as ByteString (for lookup arguments)
348343
generateKeyBS :: (StatefulGen g m) => g -> m ByteString
349344
generateKeyBS = uniformByteStringM Value.maxKeyLen
345+
346+
-- | Generate positive quantities (1 to 1000000)
347+
genQuantity :: Int -> Int -> Integer
348+
genQuantity policyIndex tokenIndex =
349+
fromIntegral (1 + (policyIndex * 1_000 + tokenIndex) `mod` 1_000_000)

plutus-core/cost-model/budgeting-bench/Common.hs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,3 +431,36 @@ createThreeTermBuiltinBenchWithWrappers (wrapX, wrapY, wrapZ) fun tys xs ys zs =
431431
[mkBM x y z | z <- zs] | y <- ys] | x <- xs]
432432
where mkBM x y z = benchDefault (showMemoryUsage (wrapZ z)) $ mkApp3 fun tys x y z
433433

434+
{- See Note [Adjusting the memory usage of arguments of costing benchmarks]. -}
435+
createFourTermBuiltinBenchElementwiseWithWrappers
436+
:: ( fun ~ DefaultFun
437+
, uni ~ DefaultUni
438+
, uni `HasTermLevel` a
439+
, uni `HasTermLevel` b
440+
, uni `HasTermLevel` c
441+
, uni `HasTermLevel` d
442+
, ExMemoryUsage a'
443+
, ExMemoryUsage b'
444+
, ExMemoryUsage c'
445+
, ExMemoryUsage d'
446+
, NFData a
447+
, NFData b
448+
, NFData c
449+
, NFData d
450+
)
451+
=> (a -> a', b -> b', c -> c', d -> d')
452+
-> fun
453+
-> [Type tyname uni ()]
454+
-> [(a,b,c,d)]
455+
-> Benchmark
456+
createFourTermBuiltinBenchElementwiseWithWrappers (wrapW, wrapX, wrapY, wrapZ) fun tys inputs =
457+
bgroup (show fun) $
458+
fmap
459+
(\(w, x, y, z) ->
460+
bgroup (showMemoryUsage $ wrapW w)
461+
[bgroup (showMemoryUsage $ wrapX x)
462+
[bgroup (showMemoryUsage $ wrapY y) [mkBM w x y z]]
463+
]
464+
)
465+
inputs
466+
where mkBM w x y z = benchDefault (showMemoryUsage $ wrapZ z) $ mkApp4 fun tys w x y z

0 commit comments

Comments
 (0)