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

Some minor changes #8

Merged
merged 1 commit into from
Dec 15, 2021
Merged
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
13 changes: 6 additions & 7 deletions src/benchy.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ proc total(s: seq[SomeNumber]): float =
proc min(s: seq[SomeNumber]): float =
## Computes mean (average) of a sequence.
result = s[0].float
for v in s[1 .. ^1]:
result = min(v.float, result)
for i in 1..s.high:
result = min(s[i].float, result)

proc mean(s: seq[SomeNumber]): float =
## Computes mean (average) of a sequence.
Expand Down Expand Up @@ -41,8 +41,8 @@ proc removeOutliers(s: var seq[SomeNumber]) =
while i < s.len:
if abs(s[i] - avg) > std*2:
s.delete(i)
continue
inc i
else:
inc i

var
shownHeader = false # Only show the header once.
Expand All @@ -56,10 +56,9 @@ template keep*(value: untyped) =
keepInt = keepInt and 0xFFFF
#keepInt = cast[int](value)

proc dots(n: int): string =
template dots(n: Natural): string =
## Drop a bunch of dots.
for i in 0 ..< n:
result.add(".")
repeat('.', n)

template timeIt*(tag: string, iterations: untyped, body: untyped) =
## Template to time block of code.
Expand Down