Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple benchmark script #3

Merged
merged 1 commit into from Apr 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions benchmark.py
@@ -0,0 +1,16 @@
import sys
from timeit import timeit

from leven import levenshtein

n_runs = 30

with open("/usr/share/dict/words") as f:
strs = [ln.strip() for ln in f]
print("Running %d times on %d reference strings" % (n_runs, len(strs)))

arg = sys.argv[1]
t = timeit(stmt='for s in strs: levenshtein(arg, s)',
setup='from __main__ import arg, levenshtein, strs',
number=n_runs)
print("%.3f seconds" % t)