diff options
| author | Taras Madan <tarasmadan@google.com> | 2021-12-15 18:12:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-15 18:12:41 +0100 |
| commit | 572bcb406b5d48ce06b3becd1ac9463d0a54329b (patch) | |
| tree | 4858d2f3cfcc3ef60589d150c1e0154340480e2d /syz-verifier/stats.go | |
| parent | d5901839ce996fefa76d58d693d687c6637b71a6 (diff) | |
syz-verifier: use int64 instead of int for statistics (#2924)
Currently we use int to aggregate statistics.
Counters update require the lock() operation.
Lets relax it and move to int64 + atomic.AddInt64().
Diffstat (limited to 'syz-verifier/stats.go')
| -rw-r--r-- | syz-verifier/stats.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/syz-verifier/stats.go b/syz-verifier/stats.go index e06ead8c0..17a443315 100644 --- a/syz-verifier/stats.go +++ b/syz-verifier/stats.go @@ -17,10 +17,10 @@ import ( type Stats struct { // Calls stores statistics for all supported system calls. Calls map[string]*CallStats - TotalMismatches int - TotalProgs int - FlakyProgs int - MismatchingProgs int + TotalMismatches int64 + TotalProgs int64 + FlakyProgs int64 + MismatchingProgs int64 StartTime time.Time } @@ -31,10 +31,10 @@ type CallStats struct { Name string // Mismatches stores the number of errno mismatches identified in the // verified programs for this system call. - Mismatches int + Mismatches int64 // Occurrences is the number of times the system call appeared in a // verified program. - Occurrences int + Occurrences int64 // States stores the kernel return state that caused mismatches. States map[ReturnState]bool } @@ -95,8 +95,8 @@ func (stats *Stats) getCallStatsTextDescription(call string) string { getPercentage(mismatches, stats.TotalMismatches), len(syscallStat.States), stats.getOrderedStates(syscallName)) } -func (stats *Stats) totalCallsExecuted() int { - t := 0 +func (stats *Stats) totalCallsExecuted() int64 { + var t int64 for _, cs := range stats.Calls { t += cs.Occurrences } @@ -128,6 +128,6 @@ func (stats *Stats) getOrderedStates(call string) []string { return ss } -func getPercentage(value, total int) float64 { +func getPercentage(value, total int64) float64 { return float64(value) / float64(total) * 100 } |
