Skip to content

Commit

Permalink
test: request overheads
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Dec 16, 2024
1 parent 69b69f9 commit b916878
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
17 changes: 17 additions & 0 deletions caffeination/microbenchmarks/bench_web_requests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from functools import lru_cache

import frappe
from frappe.app import application as _trigger_imports
from frappe.utils import get_test_client


def bench_request_overheads():
client = get_test_client()
for _ in range(100):
resp = client.get("/api/method/ping", headers={"X-Frappe-Site-Name": get_site()})
assert resp.status_code == 200


@lru_cache
def get_site():
return frappe.local.site
15 changes: 8 additions & 7 deletions caffeination/microbenchmarks/run_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
import pyperf
from frappe.utils import cstr

from caffeination.microbenchmarks import bench_background_jobs, bench_database, bench_orm, bench_redis
from caffeination.microbenchmarks import (
bench_background_jobs,
bench_database,
bench_orm,
bench_redis,
bench_web_requests,
)

BENCHMARK_PREFIX = "bench_"

Expand Down Expand Up @@ -48,12 +54,7 @@ def teardown(site):

def discover_benchmarks(benchmark_filter=None):
benchmark_filter = cstr(benchmark_filter)
benchmark_modules = [
bench_orm,
bench_database,
bench_redis,
bench_background_jobs,
]
benchmark_modules = [bench_orm, bench_database, bench_redis, bench_background_jobs, bench_web_requests]

benchmarks = []
for module in benchmark_modules:
Expand Down

0 comments on commit b916878

Please sign in to comment.