Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make restore benchmark slimmer #3051

Merged
merged 2 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ instance NFData (RndAnyState n p)
-- seed.
--
-- The type parameter is expected to be a ratio of addresses we ought to simply
-- recognize as ours. It is expressed in tenths of percent, so "1" means 0.1%,
-- "10" means 1% and 1000 means 100%.
-- recognize as ours. It is expressed in per-myriad, so "1" means 0.01%,
-- "100" means 1% and 10000 means 100%.
mkRndAnyState
:: forall (p :: Nat) n. ()
=> ByronKey 'RootK XPrv
Expand Down Expand Up @@ -427,7 +427,7 @@ instance KnownNat p => IsOurs (RndAnyState n p) Address where
(Nothing, _) ->
(Nothing, st)
where
p = floor (double (maxBound :: Word32) * double (natVal (Proxy @p)) / 1000)
p = floor (double (maxBound :: Word32) * double (natVal (Proxy @p)) / 10000)

double :: Integral a => a -> Double
double = fromIntegral
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -917,8 +917,8 @@ instance
-- seed.
--
-- The type parameter is expected to be a ratio of addresses we ought to simply
-- recognize as ours. It is expressed in tenths of percent, so "1" means 0.1%,
-- "10" means 1% and 1000 means 100%.
-- recognize as ours. It is expressed in per-myriad, so "1" means 0.01%,
-- "100" means 1% and 10000 means 100%.
mkSeqAnyState
:: forall (p :: Nat) n k.
( SoftDerivation k
Expand Down Expand Up @@ -957,7 +957,7 @@ instance
| otherwise =
(Nothing, st)
where
p = floor (double sup * double (natVal (Proxy @p)) / 1000)
p = floor (double sup * double (natVal (Proxy @p)) / 10000)
where
sup = maxBound :: Word32

Expand Down
27 changes: 11 additions & 16 deletions lib/shelley/bench/restore-bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ cardanoRestoreBench tr c socketFile = do
benchmarksSeq

let benchRestoreRndWithOwnership p = do
let benchname = showPercentFromPermille p <> "-percent-rnd"
let benchname = showPercentFromPermyriad p <> "-percent-rnd"
bench_restoration
networkProxy
(trMessageText tr)
Expand All @@ -288,7 +288,7 @@ cardanoRestoreBench tr c socketFile = do
benchmarksRnd

let benchRestoreSeqWithOwnership p = do
let benchname = showPercentFromPermille p <> "-percent-seq"
let benchname = showPercentFromPermyriad p <> "-percent-seq"
bench_restoration
networkProxy
(trMessageText tr)
Expand All @@ -309,16 +309,11 @@ cardanoRestoreBench tr c socketFile = do
-- to-100% time.
benchRestoreMultipleWallets 1 (unsafeMkPercentage 0.1)
, benchRestoreMultipleWallets 10 (unsafeMkPercentage 0.01)
, benchRestoreMultipleWallets 20 (unsafeMkPercentage 0.01)
, benchRestoreMultipleWallets 40 (unsafeMkPercentage 0.01)
, benchRestoreMultipleWallets 80 (unsafeMkPercentage 0.01)
, benchRestoreMultipleWallets 100 (unsafeMkPercentage 0.01)

, benchRestoreSeqWithOwnership (Proxy @0)
, benchRestoreSeqWithOwnership (Proxy @2)

, benchRestoreRndWithOwnership (Proxy @0)
, benchRestoreRndWithOwnership (Proxy @2)
, benchRestoreSeqWithOwnership (Proxy @1)
, benchRestoreRndWithOwnership (Proxy @1)
]
where
walletRnd
Expand Down Expand Up @@ -836,16 +831,16 @@ instance NetworkDiscriminantVal n => ToText (BenchmarkLog n) where
"Fetching tip failed, retrying in " +|| (delay `div` 1000) ||+ "ms"


-- | Format a type-level per-mille number as percent
-- | Format a type-level per-myriad number as percent
--
-- >>> showPercentFromPermille (Proxy @1)
-- "0.1"
-- >>> showPercentFromPermyriad (Proxy @1)
-- "0.01"
--
-- >>> showPercentFromPermille (Proxy @0)
-- >>> showPercentFromPermyriad (Proxy @0)
-- "0"
showPercentFromPermille :: forall (p :: Nat) . KnownNat p => Proxy p -> Text
showPercentFromPermille =
T.pack . display . (/10) . fromRational . toRational . natVal
showPercentFromPermyriad :: forall (p :: Nat) . KnownNat p => Proxy p -> Text
showPercentFromPermyriad =
T.pack . display . (/100) . fromRational . toRational . natVal
where
-- I cannot find a haskell way to format a rational with a /minimum/ number
-- of decimals, so this will do.
Expand Down