Skip to content

Commit 2054e4a

Browse files
authored
atbash.py: Tighten up the benchmarks
1 parent 8951d85 commit 2054e4a

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

ciphers/atbash.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,13 @@ def atbash(sequence: str) -> str:
3838

3939

4040
def benchmark() -> None:
41-
"""Let's benchmark them side-by-side..."""
41+
"""Let's benchmark our functions side-by-side..."""
4242
from timeit import timeit
4343

4444
print("Running performance benchmarks...")
45-
print(
46-
"> atbash_slow()",
47-
timeit(
48-
"atbash_slow(printable)",
49-
setup="from string import printable ; from __main__ import atbash_slow",
50-
),
51-
"seconds",
52-
)
53-
print(
54-
"> atbash()",
55-
timeit(
56-
"atbash(printable)",
57-
setup="from string import printable ; from __main__ import atbash",
58-
),
59-
"seconds",
60-
)
45+
setup = "from string import printable ; from __main__ import atbash, atbash_slow"
46+
print(f"> atbash_slow(): {timeit('atbash_slow(printable)', setup=setup)} seconds")
47+
print(f"> atbash(): {timeit('atbash(printable)', setup=setup)} seconds")
6148

6249

6350
if __name__ == "__main__":

0 commit comments

Comments
 (0)