Skip to content

Commit 4cddb26

Browse files
cclaussgithub-actions
and
github-actions
authored
atbash.py: Tighten up the benchmarks (TheAlgorithms#7977)
* atbash.py: Tighten up the benchmarks * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
1 parent 076193e commit 4cddb26

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

DIRECTORY.md

+1
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,7 @@
995995
* [Sol1](project_euler/problem_686/sol1.py)
996996

997997
## Quantum
998+
* [Bb84](quantum/bb84.py)
998999
* [Deutsch Jozsa](quantum/deutsch_jozsa.py)
9991000
* [Half Adder](quantum/half_adder.py)
10001001
* [Not Gate](quantum/not_gate.py)

ciphers/atbash.py

+4-17
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)