Skip to content

Commit

Permalink
Merge pull request #196 from leanprover/fix-geomean
Browse files Browse the repository at this point in the history
chore: fix geomean computation
  • Loading branch information
bollu authored Sep 26, 2024
2 parents 430db90 + df183f1 commit 0194790
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Benchmarks/Command.lean
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ elab "benchmark" id:ident declSig:optDeclSig val:declVal : command => do
let n := 5
let mut runTimes := #[]
let mut totalRunTime := 0
-- geomean = exp(log((a₁ a₂ ... aₙ)^1/n)) =
-- exp(1/n * (log a₁ + log a₂ + log aₙ)).
let mut totalRunTimeLog := 0
for _ in [0:n] do
let start ← IO.monoMsNow
elabCommand stx
let endTime ← IO.monoMsNow
let runTime := endTime - start
runTimes := runTimes.push runTime
totalRunTime := totalRunTime + runTime
totalRunTimeLog := totalRunTimeLog + Float.log runTime.toFloat

let avg := totalRunTime.toFloat / n.toFloat / 1000
let geomean := (totalRunTime.toFloat.pow (1.0 / n.toFloat)) / 1000.0
let geomean := (Float.exp (totalRunTimeLog / n.toFloat)) / 1000.0
logInfo m!"\
{id}:
average runtime over {n} runs:
Expand Down

0 comments on commit 0194790

Please sign in to comment.