Skip to content

Commit

Permalink
Improve benchmark autonumber accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
shBLOCK committed May 11, 2024
1 parent a498840 commit 6aeb471
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 5 additions & 4 deletions benchmark/benchmarking.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,13 @@ def update(self):

def auto_number(self) -> int:
assert self.is_auto_number
for expo in itertools.count(3):
for n in (1, 2, 5):
self.number = n * 10**expo
runtime = self.run().runtime
for self.number in auto_number_series():
with temp_log():
log(numerize(self.number, decimals=1), False)
runtime = min(self.run().runtime for _ in range(5))
if runtime > AUTO_NUMBER_TARGET_TIME:
return runtime
self.number = int(self.number * 1.1)

def run(self) -> "TestCaseResult":
log(".", False)
Expand Down
9 changes: 8 additions & 1 deletion benchmark/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@
"log",
"indent_log",
"temp_log",
"iter_identity"
"iter_identity",
"auto_number_series"
)

SourceLines = Tuple[str, ...]

def auto_number_series() -> Generator[int, None, None]:
for expo in itertools.count(2):
# E12 series
for value in (10, 12, 15, 18, 22, 27, 33, 39, 47, 56, 68, 82):
yield value * 10 ** expo

def indent(src: SourceLines) -> SourceLines:
return tuple(" "*4 + line for line in src)

Expand Down

0 comments on commit 6aeb471

Please sign in to comment.