mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11: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)
|
* [Sol1](project_euler/problem_686/sol1.py)
|
||||||
|
|
||||||
## Quantum
|
## Quantum
|
||||||
|
* [Bb84](quantum/bb84.py)
|
||||||
* [Deutsch Jozsa](quantum/deutsch_jozsa.py)
|
* [Deutsch Jozsa](quantum/deutsch_jozsa.py)
|
||||||
* [Half Adder](quantum/half_adder.py)
|
* [Half Adder](quantum/half_adder.py)
|
||||||
* [Not Gate](quantum/not_gate.py)
|
* [Not Gate](quantum/not_gate.py)
|
||||||
|
|
|
@ -38,26 +38,13 @@ def atbash(sequence: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
def benchmark() -> None:
|
def benchmark() -> None:
|
||||||
"""Let's benchmark them side-by-side..."""
|
"""Let's benchmark our functions side-by-side..."""
|
||||||
from timeit import timeit
|
from timeit import timeit
|
||||||
|
|
||||||
print("Running performance benchmarks...")
|
print("Running performance benchmarks...")
|
||||||
print(
|
setup = "from string import printable ; from __main__ import atbash, atbash_slow"
|
||||||
"> atbash_slow()",
|
print(f"> atbash_slow(): {timeit('atbash_slow(printable)', setup=setup)} seconds")
|
||||||
timeit(
|
print(f"> atbash(): {timeit('atbash(printable)', setup=setup)} seconds")
|
||||||
"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",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user