forked from openmaptiles/openmaptiles-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-perf
executable file
·110 lines (98 loc) · 4.98 KB
/
test-perf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python
"""
Refresh all PostgreSQL materialized views in parallel, taking into account cross-dependencies.
Usage:
test-perf <tileset> [--test=<set>]... [--layer=<layer>]... [--exclude-layers]
[--per-layer] [--summary] [--test-all]
([--zoom=<zoom>]... | [--minzoom=<min>] [--maxzoom=<max>])
[--record=<file>] [--compare=<file>] [--buckets=<count>]
[--key] [--gzip [<gzlevel>]] [--no-color] [--no-feature-ids]
[--no-tile-envelope] [--test-geometry] [--verbose]
[--pghost=<host>] [--pgport=<port>] [--dbname=<db>]
[--user=<user>] [--password=<password>]
test-perf --help
test-perf --version
<tileset> Tileset definition yaml file
Options:
-t --test=<set> Which predefined test to run. [default: us-across]
Use invalid value to see a list. Use 'null' for PostGIS < v2.5
-a --test-all Run all available tests except 'null'
-p --per-layer Test each layer individually, also show per-layer summary graph.
-s --summary Run summary tests, without per-tile break-down.
-l --layer=<layers> Limit testing to a specific layer (could be more than one)
-x --exclude-layers If set, uses all layers except the ones listed with -l (-l is required)
-z --zoom=<zoom> Limit testing to a specific zoom. If set, ignores min/max.
-m --minzoom=<min> Test tiles in zooms more or equal to this value [default: 14]
-n --maxzoom=<max> Test tiles in zooms less or equal to this value [default: 14]
-r --record=<file> Record results into a json file for later use with --compare.
-c --compare=<file> Compare performance run results with a previous run
-b --buckets=<count> Show up to this many buckets in a graph [default: 10]
--key Generate md5 keys for all tiles (resulting key is ignored)
--gzip If set, compress MVT with gzip, with optional level=0..9.
--no-color Disable ANSI colors
--no-feature-ids Disable feature ID generation, e.g. from osm_id.
Feature IDS are automatically disabled with PostGIS before v3.
--no-tile-envelope Disable PostGIS 3.0+ ST_TileEnvelope() function.
ST_TileEnvelope() is auto-disabled with PostGIS before v3.
-v --verbose Print additional debugging information.
--help Show this screen.
--version Show version.
PostgreSQL Connection Options:
-h --pghost=<host> Postgres hostname. By default uses PGHOST env or "localhost" if not set.
-P --pgport=<port> Postgres port. By default uses PGPORT env or "5432" if not set.
-d --dbname=<db> Postgres db name. By default uses PGDATABASE env or "openmaptiles" if not set.
-U --user=<user> Postgres user. By default uses PGUSER env or "openmaptiles" if not set.
--password=<password> Postgres password. By default uses PGPASSWORD env or "openmaptiles" if not set.
Postgres
These legacy environment variables should not be used, but they are still supported:
POSTGRES_HOST, POSTGRES_PORT, POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD
"""
import asyncio
import os.path
from docopt import docopt
import openmaptiles
from openmaptiles.performance import PerfTester
from openmaptiles.perfutils import COLOR
from openmaptiles.utils import coalesce
def main(args):
if args['--no-color']:
COLOR.enable(False)
zooms = [int(v) for v in args['--zoom']]
if not zooms:
zooms = list(range(int(args['--minzoom']), int(args['--maxzoom']) + 1))
perf = PerfTester(
tileset=args['<tileset>'],
tests=args['--test'],
test_all=args['--test-all'],
summary=args['--summary'],
per_layer=args['--per-layer'],
layers=args['--layer'],
exclude_layers=args['--exclude-layers'],
buckets=int(args['--buckets']),
zooms=zooms,
pghost=coalesce(
args.get("--pghost"), os.getenv('POSTGRES_HOST'), os.getenv('PGHOST'),
'localhost'),
pgport=coalesce(
args.get("--pgport"), os.getenv('POSTGRES_PORT'), os.getenv('PGPORT'),
'5432'),
dbname=coalesce(
args.get("--dbname"), os.getenv('POSTGRES_DB'), os.getenv('PGDATABASE'),
'openmaptiles'),
user=coalesce(
args.get("--user"), os.getenv('POSTGRES_USER'), os.getenv('PGUSER'),
'openmaptiles'),
password=coalesce(
args.get("--password"), os.getenv('POSTGRES_PASSWORD'),
os.getenv('PGPASSWORD'), 'openmaptiles'),
save_to=args['--record'],
compare_with=args['--compare'],
disable_feature_ids=args['--no-feature-ids'],
disable_tile_envelope=args['--no-tile-envelope'],
key_column=args['--key'],
gzip=args['--gzip'] and (args['<gzlevel>'] or True),
verbose=args.get('--verbose'),
)
asyncio.run(perf.run())
if __name__ == '__main__':
main(docopt(__doc__, version=openmaptiles.__version__))