mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-01 12:26:19 -05:00
Use exponential curve for large map files.
This commit is contained in:
parent
369da8a9b7
commit
f44ac91319
2 changed files with 11 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue