Use exponential curve for large map files.

This commit is contained in:
Roland 2023-09-07 13:01:19 -06:00
parent 369da8a9b7
commit f44ac91319
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 11 additions and 1 deletions

View file

@ -230,4 +230,10 @@ RPI4_PBF_BYTES_PER_SECOND = 61879
def seconds_to_import(size_in_bytes: int) -> int:
"""Attempt to predict how long it will take an RPi4 to import a given PBF file."""
if size_in_bytes > 1_000_000_000:
# Use exponential curve for large files. These magic numbers are from testing many imports on an RPi 4.
a = 7.17509261732342e-14 * size_in_bytes ** 2
b = 6.6590760410412e-5 * size_in_bytes
c = 10283
return int(a - b + c)
return max(int(size_in_bytes // RPI4_PBF_BYTES_PER_SECOND), 0)

View file

@ -73,8 +73,12 @@ async def test_run_import_command(test_directory, mock_create_subprocess_shell):
(17737381, 286),
(63434267, 1025),
(87745484, 1418),
(136372996, 2203),
(116318111, 1879),
(136372996, 2203),
(1936075318, 150308),
(2676094489, 345922),
(3392375001, 610106),
(11346305075, 8491840),
])
def test_seconds_to_import_rpi4(size, expected):
assert lib.seconds_to_import(size) == expected