missing avg function for int

This commit is contained in:
thatben 2025-03-06 16:32:33 +01:00
parent d95ff2f73d
commit e3dd68a13d
No known key found for this signature in database
GPG Key ID: 62C543548433D43E

View File

@ -22,6 +22,11 @@ func avg(vals: openArray[float]): float =
for v in vals:
result += v / vals.len().toFloat()
func avg(vals: openArray[int]): int =
for v in vals:
result += v
result = result div vals.len()
template benchmark*(name: untyped, count: int, blk: untyped) =
let benchmarkName: string = name
## simple benchmarking of a block of code