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

minor tweaks on the stats class. #443

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions egklib/src/commonMain/kotlin/electionguard/util/Stats.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(",")}")
}
}
}
8 changes: 5 additions & 3 deletions egklib/src/jvmMain/kotlin/electionguard/core/Group.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down