Skip to content

Commit

Permalink
Benchmarking stuff updated to test with a more realistic dataset (the…
Browse files Browse the repository at this point in the history
… PuTTY

manual).


git-svn-id: svn+userv://snowball.tartarus.org/snowball/trunk/pystemmer@372 633ccae0-01f4-0310-8c99-d3591da6f01f
  • Loading branch information
rboulton committed Jun 11, 2006
1 parent a1d0ee2 commit 7f3cf0c
Show file tree
Hide file tree
Showing 4 changed files with 37,595 additions and 10 deletions.
37 changes: 37 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,40 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

License for sample data files
=============================

There are two files in the "sampledata/" subdirectory, used for benchmarking.
The first of these, "englishvoc.txt", is the english vocabulary list from
snowball, and is covered by the same license as snowball itself (ie, the BSD
license, see above).

The second of these files, "puttydoc.txt", is the text form of the manual for
the "PuTTY" piece of software, which is covered by the following license.

PuTTY is copyright 1997-2006 Simon Tatham.

Portions copyright Robert de Bath, Joris van Rantwijk, Delian
Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry,
Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, Markus
Kuhn, and CORE SDI S.A.

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 changes: 20 additions & 10 deletions benchmark.py
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))
Loading

0 comments on commit 7f3cf0c

Please sign in to comment.