Files
Aislo/resources/tester/test_preview_cost.py
T
eomsangdonandClaude Opus 5 1a82df951f revert(tester): 서식만 바뀐 남의 시험 파일 25개 되돌림
ruff 글로브를 `resources/tester/*.py` 로 넓게 잡아 내 작업과 무관한 시험 파일까지
서식이 바뀌었음. 다른 창이 그 파일을 만지면 충돌만 남으므로 되돌림.
내가 실제로 고친 다섯(열쇠 장부·Z01 둘·표 읽기·못 읽은 표)만 남김.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsGw1Dz9HmhuAxGisxmDPF
2026-09-17 19:42:32 +09:00

53 lines
1.9 KiB
Python

"""미리보기 점 수집이 업로드 분석 시간을 늘리지 않는지 (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:
# ⚠ 시험이 `tmp/tests` → `resources/tester` 로 옮겨졌다(2026-09-09). 옛 경로로 부르면
# 옮긴 폴더에서 못 찾는다 — 같은 폴더의 짝을 새 경로로 부른다.
from resources.tester.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