From 42f1901e5692a4e50b81d1cbd0ee0333a6293ed4 Mon Sep 17 00:00:00 2001 From: JohnLCaron Date: Sat, 6 Jan 2024 05:32:23 -0700 Subject: [PATCH] minor tweaks on the stats class. remove print list of ballot ids on Accumulatetally. --- .../commonMain/kotlin/electionguard/core/GroupCommon.kt | 6 +++++- egklib/src/commonMain/kotlin/electionguard/util/Stats.kt | 7 +++++++ .../kotlin/electionguard/cli/RunAccumulateTally.kt | 2 +- egklib/src/jvmMain/kotlin/electionguard/core/Group.kt | 8 +++++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/egklib/src/commonMain/kotlin/electionguard/core/GroupCommon.kt b/egklib/src/commonMain/kotlin/electionguard/core/GroupCommon.kt index 33561bcd..19cbfaad 100644 --- a/egklib/src/commonMain/kotlin/electionguard/core/GroupCommon.kt +++ b/egklib/src/commonMain/kotlin/electionguard/core/GroupCommon.kt @@ -202,7 +202,11 @@ interface GroupContext { */ fun dLogG(p: ElementModP, maxResult: Int = - 1): Int? - fun showAndClearCountPowP() : String + fun showAndClearCountPowP(count :CountExp? = null) : String +} + +class CountExp(var exp: Int, var acc: Int) { + constructor(): this(0,0) } interface Element { diff --git a/egklib/src/commonMain/kotlin/electionguard/util/Stats.kt b/egklib/src/commonMain/kotlin/electionguard/util/Stats.kt index 07694719..66a48743 100644 --- a/egklib/src/commonMain/kotlin/electionguard/util/Stats.kt +++ b/egklib/src/commonMain/kotlin/electionguard/util/Stats.kt @@ -18,6 +18,13 @@ class Stats { } } + fun show(who: String) { + val stat = stats.get(who) + if (stat != null) println(stat.show()) else println("no stat named $who") + } + + fun get(who: String) : Stat? = stats.get(who) + fun show(len: Int = 3) { showLines(len).forEach { println(it) } } diff --git a/egklib/src/jvmMain/kotlin/electionguard/cli/RunAccumulateTally.kt b/egklib/src/jvmMain/kotlin/electionguard/cli/RunAccumulateTally.kt index 75df8078..d2730764 100644 --- a/egklib/src/jvmMain/kotlin/electionguard/cli/RunAccumulateTally.kt +++ b/egklib/src/jvmMain/kotlin/electionguard/cli/RunAccumulateTally.kt @@ -129,7 +129,7 @@ class RunAccumulateTally { val took = getSystemTimeInMillis() - starting val msecPerEncryption = if (countOk == 0) 0 else (took.toDouble() / countOk).roundToInt() println("AccumulateTally processed $countOk good ballots, $countBad bad ballots, took $took millisecs, $msecPerEncryption msecs per good ballot") - println(" ballots ids accumulated = ${tally.castBallotIds.joinToString(",")}") + // println(" ballots ids accumulated = ${tally.castBallotIds.joinToString(",")}") } } } diff --git a/egklib/src/jvmMain/kotlin/electionguard/core/Group.kt b/egklib/src/jvmMain/kotlin/electionguard/core/Group.kt index 9da9ca62..a29ad05c 100644 --- a/egklib/src/jvmMain/kotlin/electionguard/core/Group.kt +++ b/egklib/src/jvmMain/kotlin/electionguard/core/Group.kt @@ -266,10 +266,12 @@ class ProductionGroupContext( override fun dLogG(p: ElementModP, maxResult: Int): Int? = dlogger.dLog(p, maxResult) - // temp debug - - override fun showAndClearCountPowP() : String { + override fun showAndClearCountPowP(count :CountExp?) : String { val result = "countPowP,AccPowP= ${countPow}, $countAccPowP total= ${countPow.get()+countAccPowP.get()}" + if (count != null) { + count.exp = countPow.get() + count.acc = countAccPowP.get() + } countPow.set(0) countAccPowP.set(0) return result