Skip to content

Commit

Permalink
Merge pull request #443 from JohnLCaron/stats
Browse files Browse the repository at this point in the history
minor tweaks on the stats class.
  • Loading branch information
JohnLCaron authored Jan 6, 2024
2 parents a2773c3 + 42f1901 commit be1a34f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
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

0 comments on commit be1a34f

Please sign in to comment.