Files
DECNET/tests/perf/test_repo_bench.py
anti f2b3393669 chore: relicense to AGPL-3.0-or-later and add SPDX headers
Replaces LICENSE (GPLv3 -> AGPLv3) and prepends
`SPDX-License-Identifier: AGPL-3.0-or-later` to every source file
across decnet/, decnet_web/, tests/, scripts/, and tools/.

Rationale: closes the GPLv3 ASP loophole so any party operating a
modified DECNET as a network service must offer their modified
source. Personal copyright (Samuel Paschuan) + inbound=outbound
contributions make a future unilateral relicense infeasible.

- LICENSE: full AGPL-3.0 text (gnu.org/licenses/agpl-3.0.txt)
- COPYRIGHT: project copyright notice
- tools/add_spdx_headers.py: idempotent header injector
  (shebang- and PEP 263-aware)

Touches 1565 source files (.py, .ts, .tsx, .js, .jsx, .css, .sh).
No behavior change; comments only.
2026-05-22 21:04:16 -04:00

62 lines
1.4 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Micro-benchmarks for the repository hot paths.
Run with:
pytest -m bench tests/perf/
These do NOT run in the default suite (see `addopts` in pyproject.toml).
"""
import pytest
pytestmark = pytest.mark.bench
def test_add_log_bench(benchmark, repo, event_loop):
payload = {
"decky": "decky-bench",
"service": "ssh",
"event_type": "connect",
"attacker_ip": "10.0.0.1",
"raw_line": "bench event",
"fields": "{}",
"msg": "",
}
def run():
event_loop.run_until_complete(repo.add_log(payload))
benchmark(run)
def test_get_logs_bench(benchmark, seeded_repo, event_loop):
def run():
return event_loop.run_until_complete(seeded_repo.get_logs(limit=50, offset=0))
result = benchmark(run)
assert len(result) == 50
def test_get_total_logs_bench(benchmark, seeded_repo, event_loop):
def run():
return event_loop.run_until_complete(seeded_repo.get_total_logs())
benchmark(run)
def test_get_logs_search_bench(benchmark, seeded_repo, event_loop):
def run():
return event_loop.run_until_complete(
seeded_repo.get_logs(limit=50, offset=0, search="service:ssh")
)
benchmark(run)
def test_get_user_by_username_bench(benchmark, seeded_repo, event_loop):
def run():
return event_loop.run_until_complete(seeded_repo.get_user_by_username("admin"))
benchmark(run)