forked from snowballstem/pystemmer
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Benchmarking stuff updated to test with a more realistic dataset (the…
… PuTTY manual). git-svn-id: svn+userv://snowball.tartarus.org/snowball/trunk/pystemmer@372 633ccae0-01f4-0310-8c99-d3591da6f01f
- Loading branch information
Showing
4 changed files
with
37,595 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
#!/usr/bin/env python | ||
|
||
# This script runs a simple benchmark of the python stemmer interface. | ||
|
||
import timeit | ||
|
||
for cache_size in (0, 1, 10000, 30000): | ||
setup = r""" | ||
datafiles = ('sampledata/englishvoc.txt', 'sampledata/puttydoc.txt',) | ||
words_lst = [None] | ||
|
||
for datafile in datafiles: | ||
words = [] | ||
for line in open(datafile): | ||
words.extend(line.split()) | ||
for cache_size in (0, 1, 10000, 30000): | ||
setup = r""" | ||
import Stemmer | ||
stemmer = Stemmer.Stemmer('en', %d) | ||
fd = open('../data/english/voc.txt') | ||
words = fd.readlines() | ||
""" % cache_size | ||
t = timeit.Timer(setup=setup, | ||
stmt='stemmer.stemWords(words)') | ||
for iters in (1, 2, 3, 10): | ||
times = [time / iters for time in t.repeat(5, iters)] | ||
print "cacheSize=%d,iters=%d,time=%f" % (cache_size, iters, min(times)) | ||
words = [] | ||
for line in open('%s'): | ||
words.extend(line.split()) | ||
""" % (cache_size, datafile) | ||
t = timeit.Timer(setup=setup, | ||
stmt='stemmer.stemWords(words)') | ||
for iters in (1, 2, 3, 10): | ||
times = [time / iters for time in t.repeat(5, iters)] | ||
print "'%s':words=%d,cacheSize=%d,iters=%d,mintime=%f" % (datafile, len(words), cache_size, iters, min(times)) |
Oops, something went wrong.