File: benchmarks.py

package info (click to toggle)
morecantile 7.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,036 kB
  • sloc: python: 3,339; makefile: 5
file content (43 lines) | stat: -rw-r--r-- 1,218 bytes parent folder | download | duplicates (2)
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
"""Morecantile benchmark."""

import pytest

import morecantile
from morecantile.commons import BoundingBox

tms = morecantile.tms.get("WebMercatorQuad")

# Test tiles from https://github.com/jessekrubin/utiles/blob/ea58b9a017a2e3528f03cc20f16ef531737b863f/utiles-pyo3/bench/test_bench.py
TEST_TILES = (
    (0, 0, 0),
    (1, 0, 1),
    (1, 1, 1),
    (1, 40, 7),
    (486, 332, 10),
    # HIGH ZOOM
    (486, 332, 20),
    # OUTSIDE TMS Range
    (486, 332, 30),
)


@pytest.mark.parametrize("tile", TEST_TILES)
def test_bounds(tile, benchmark):
    str_tile = "Tile(x={},y={},z={})".format(*tile)
    benchmark.name = f"morecantile.bounds-{str_tile}"
    benchmark.fullname = f"morecantile.bounds-{str_tile}"
    benchmark.group = "morecantile.bounds"

    r = benchmark(tms.bounds, *tile)
    assert isinstance(r, BoundingBox)


@pytest.mark.parametrize("tile", TEST_TILES)
def test_xy_bounds(tile, benchmark) -> None:
    str_tile = "Tile(x={},y={},z={})".format(*tile)
    benchmark.name = f"morecantile.xy_bounds-{str_tile}"
    benchmark.fullname = f"morecantile.xy_bounds-{str_tile}"
    benchmark.group = "morecantile.xy_bounds"

    r = benchmark(tms.xy_bounds, *tile)
    assert isinstance(r, BoundingBox)