touchup and actuall install the 'howfast.py' little performance testing script

This commit is contained in:
Dane Springmeyer 2010-12-16 16:32:06 +00:00
parent 3c8e751887
commit 20349d42f6
3 changed files with 46 additions and 11 deletions

View file

@ -1386,7 +1386,12 @@ if not HELP_REQUESTED:
# Build the Python bindings
if 'python' in env['BINDINGS']:
SConscript('bindings/python/SConscript')
SConscript('utils/upgrade_map_xml/SConscript')
# Install the python speed testing scripts if python bindings will be available
SConscript('utils/performance/SConscript')
# Install the mapnik2 upgrade script
SConscript('utils/upgrade_map_xml/SConscript')
# Configure fonts and if requested install the bundled DejaVu fonts
SConscript('fonts/SConscript')

View file

@ -0,0 +1,33 @@
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2010 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# $Id$
Import ('env')
prefix = env['PREFIX']
install_prefix = env['DESTDIR'] + '/' + prefix
TARGET = 'howfast.py'
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_prefix + '/bin', TARGET)
env.Alias('install', install_prefix + '/bin')
env['create_uninstall_target'](env, install_prefix + '/bin/' + TARGET)

View file

@ -8,16 +8,9 @@ from timeit import Timer, time
if not len(sys.argv) >= 3:
sys.exit('usage: howfast.py <stylesheet> <iterations> [minx,miny,maxx,maxy]')
if not hasattr(mapnik,'Envelope'):
mapnik.Envelope = mapnik.Box2d
if not hasattr(mapnik,'Box2d'):
mapnik.Box2d = mapnik.Envelope
m = mapnik.Map(256,256)
mapnik.load_map(m,sys.argv[1])
m.zoom_all()
ver = mapnik.mapnik_version()
TOTAL_TIME = 0
BBOX = None
@ -32,10 +25,10 @@ def test():
def f_(set):
min_ = str(min(set))[:6]
avg = str(sum(set)/len(set))[:6]
print '%s: min: %s | avg: %s | total: %s' % (ver,min_,avg,str(TOTAL_TIME)[:6])
print 'min: %s | avg: %s | total: %s' % (min_,avg,str(TOTAL_TIME)[:6])
if __name__=='__main__':
iters = int(sys.argv[2])
# if passed, set up bbox
if len(sys.argv) == 4:
bbox = sys.argv[3]
@ -49,5 +42,9 @@ if __name__=='__main__':
# load once - making sure mmap'd shapefiles are loaded
test_ = "test()"
eval(test_)
TOTAL_TIME = 0
# now actually run the test
t = Timer(test_, "from __main__ import test")
f_(t.repeat(iters,1))
iterations = int(sys.argv[2])
f_(t.repeat(iterations,1))