Skip to content

Commit

Permalink
Lower restore bench ownership by factor of 10
Browse files Browse the repository at this point in the history
  • Loading branch information
Anviking committed Dec 10, 2021
1 parent 1267289 commit 3d1abe5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
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
18 changes: 9 additions & 9 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 Down Expand Up @@ -830,16 +830,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
showPercentFromPermyraid :: 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

0 comments on commit 3d1abe5

Please sign in to comment.