mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 15:01:08 +00:00
atbash.py: Tighten up the benchmarks (#7977)
* atbash.py: Tighten up the benchmarks * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
parent
076193eefa
commit
4cddb26908
|
@ -995,6 +995,7 @@
|
|||
* [Sol1](project_euler/problem_686/sol1.py)
|
||||
|
||||
## Quantum
|
||||
* [Bb84](quantum/bb84.py)
|
||||
* [Deutsch Jozsa](quantum/deutsch_jozsa.py)
|
||||
* [Half Adder](quantum/half_adder.py)
|
||||
* [Not Gate](quantum/not_gate.py)
|
||||
|
|
|
@ -38,26 +38,13 @@ def atbash(sequence: str) -> str:
|
|||
|
||||
|
||||
def benchmark() -> None:
|
||||
"""Let's benchmark them side-by-side..."""
|
||||
"""Let's benchmark our functions side-by-side..."""
|
||||
from timeit import timeit
|
||||
|
||||
print("Running performance benchmarks...")
|
||||
print(
|
||||
"> atbash_slow()",
|
||||
timeit(
|
||||
"atbash_slow(printable)",
|
||||
setup="from string import printable ; from __main__ import atbash_slow",
|
||||
),
|
||||
"seconds",
|
||||
)
|
||||
print(
|
||||
"> atbash()",
|
||||
timeit(
|
||||
"atbash(printable)",
|
||||
setup="from string import printable ; from __main__ import atbash",
|
||||
),
|
||||
"seconds",
|
||||
)
|
||||
setup = "from string import printable ; from __main__ import atbash, atbash_slow"
|
||||
print(f"> atbash_slow(): {timeit('atbash_slow(printable)', setup=setup)} seconds")
|
||||
print(f"> atbash(): {timeit('atbash(printable)', setup=setup)} seconds")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue
Block a user