Merge branch 'improve-perftest' into remove-format-literals

This commit is contained in:
John Krauss 2016-12-08 02:21:12 +00:00
commit 4d7fb145eb
2 changed files with 18 additions and 16 deletions

View File

@ -146,7 +146,8 @@ def default_lonlat(column_id):
return (40.7, -73.9) return (40.7, -73.9)
elif column_id.startswith('eu.'): elif column_id.startswith('eu.'):
raise SkipTest('No tests for Eurostat!') raise SkipTest('No tests for Eurostat!')
#return (52.52207036136366, 13.40606689453125) elif column_id.startswith('br.'):
return (-22.9, -43.19)
else: else:
raise Exception('No catalog point set for {}'.format(column_id)) raise Exception('No catalog point set for {}'.format(column_id))

View File

@ -27,7 +27,7 @@ for q in (
-73.81885528564453,40.745696344339564, 4326), -73.81885528564453,40.745696344339564, 4326),
'us.census.tiger.census_tract_clipped')) foo 'us.census.tiger.census_tract_clipped')) foo
ORDER BY ST_NPoints(the_geom) ASC ORDER BY ST_NPoints(the_geom) ASC
LIMIT 50''', LIMIT 500''',
'DROP TABLE IF EXISTS obs_perftest_complex', 'DROP TABLE IF EXISTS obs_perftest_complex',
'''CREATE TABLE obs_perftest_complex (cartodb_id SERIAL PRIMARY KEY, '''CREATE TABLE obs_perftest_complex (cartodb_id SERIAL PRIMARY KEY,
point GEOMETRY, point GEOMETRY,
@ -45,7 +45,7 @@ for q in (
'us.census.tiger.county_clipped')) foo 'us.census.tiger.county_clipped')) foo
ORDER BY ST_NPoints(the_geom) DESC ORDER BY ST_NPoints(the_geom) DESC
LIMIT 50;''', LIMIT 50;''',
'''SET statement_timeout = 5000;''' #'''SET statement_timeout = 5000;'''
): ):
query(q.format( query(q.format(
schema='cdb_observatory.' if USE_SCHEMA else '', schema='cdb_observatory.' if USE_SCHEMA else '',
@ -94,25 +94,26 @@ def record(params, results):
('simple', 'OBS_GetCategory', None, 'geom'), ('simple', 'OBS_GetCategory', None, 'geom'),
('simple', 'OBS_GetCategory', None, 'offset_geom'), ('simple', 'OBS_GetCategory', None, 'offset_geom'),
#('complex', 'OBS_GetMeasure', 'predenominated', 'point'), ('complex', 'OBS_GetMeasure', 'predenominated', 'point'),
#('complex', 'OBS_GetMeasure', 'predenominated', 'geom'), ('complex', 'OBS_GetMeasure', 'predenominated', 'geom'),
#('complex', 'OBS_GetMeasure', 'predenominated', 'offset_geom'), ('complex', 'OBS_GetMeasure', 'predenominated', 'offset_geom'),
#('complex', 'OBS_GetMeasure', 'area', 'point'), ('complex', 'OBS_GetMeasure', 'area', 'point'),
#('complex', 'OBS_GetMeasure', 'area', 'geom'), ('complex', 'OBS_GetMeasure', 'area', 'geom'),
#('complex', 'OBS_GetMeasure', 'area', 'offset_geom'), ('complex', 'OBS_GetMeasure', 'area', 'offset_geom'),
#('complex', 'OBS_GetMeasure', 'denominator', 'point'), ('complex', 'OBS_GetMeasure', 'denominator', 'point'),
#('complex', 'OBS_GetMeasure', 'denominator', 'geom'), ('complex', 'OBS_GetMeasure', 'denominator', 'geom'),
#('complex', 'OBS_GetMeasure', 'denominator', 'offset_geom'), ('complex', 'OBS_GetMeasure', 'denominator', 'offset_geom'),
#('complex', 'OBS_GetCategory', None, 'point'), ('complex', 'OBS_GetCategory', None, 'point'),
#('complex', 'OBS_GetCategory', None, 'geom'), ('complex', 'OBS_GetCategory', None, 'geom'),
#('complex', 'OBS_GetCategory', None, 'offset_geom'), ('complex', 'OBS_GetCategory', None, 'offset_geom'),
]) ])
def test_performance(geom_complexity, api_method, normalization, geom): def test_performance(geom_complexity, api_method, normalization, geom):
print api_method, geom_complexity, normalization, geom print api_method, geom_complexity, normalization, geom
col = 'measure' if 'measure' in api_method.lower() else 'category' col = 'measure' if 'measure' in api_method.lower() else 'category'
results = [] results = []
for rows in (1, 5, 10, ): rownums = (1, 5, 10, ) if geom_complexity == 'complex' else (5, 25, 50 )
for rows in rownums:
stmt = '''UPDATE obs_perftest_{complexity} stmt = '''UPDATE obs_perftest_{complexity}
SET {col} = {schema}{api_method}({args}) SET {col} = {schema}{api_method}({args})
WHERE cartodb_id < {n}'''.format( WHERE cartodb_id < {n}'''.format(