"""미리보기 점 수집이 업로드 분석 시간을 늘리지 않는지 (2026-09-04 사용자 제약).""" import sys import time from pathlib import Path import pytest ROOT = Path(__file__).resolve().parents[2] sys.path.append(str(ROOT)) def _las_file() -> Path: from tmp.tests.test_preview_assets import _project_root # noqa: PLC0415 root = _project_root() files = sorted((root / "B03_FileInput" / "input" / "las").glob("*.la*")) if not files: pytest.skip("LAS 파일이 없습니다.") return files[0] def test_collect_cost_is_small(): import laspy import numpy as np path = _las_file() # ① 분류 통계만 (종전 동작) started = time.perf_counter() with laspy.open(path) as las_file: counts: dict[int, int] = {} for chunk in las_file.chunk_iterator(500_000): values, chunk_counts = np.unique( np.asarray(chunk.classification, dtype=np.uint8), return_counts=True ) for value, count in zip(values.tolist(), chunk_counts.tolist(), strict=True): counts[value] = counts.get(value, 0) + count baseline = time.perf_counter() - started # ② 지금 동작 (같은 길에 XY 를 성기게 주움) from B03_FileInput.B03_FileInput_Engine_Analyze import analyze_las_metadata started = time.perf_counter() meta = analyze_las_metadata(path) current = time.perf_counter() - started print(f"\n분류 통계만 {baseline:.2f}s / 점 수집 포함 {current:.2f}s " f"(차이 {current - baseline:+.2f}s, 점 {len(meta['preview_points'])}개)") # 파일을 다시 읽지 않으므로 한 번 훑는 시간과 크게 다르지 않아야 한다. assert current <= baseline * 1.5 + 1.0