snapshot of https://github.com/ActivityWatch/aw-server.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Build / Test on ubuntu-latest (push) Successful in 3m6s
Lint / lint (push) Successful in 22s
Build / typecheck (ubuntu-latest, 3.9) (push) Successful in 1m49s
Lint / format (push) Successful in 42s
Build / Test on macOS-latest (push) Has been cancelled
Build / Test on windows-latest (push) Has been cancelled
CodeQL / Analyze (python) (push) Failing after 1m31s
Some checks failed
Build / Test on ubuntu-latest (push) Successful in 3m6s
Lint / lint (push) Successful in 22s
Build / typecheck (ubuntu-latest, 3.9) (push) Successful in 1m49s
Lint / format (push) Successful in 42s
Build / Test on macOS-latest (push) Has been cancelled
Build / Test on windows-latest (push) Has been cancelled
CodeQL / Analyze (python) (push) Failing after 1m31s
This commit is contained in:
43
scripts/benchmark-api-heartbeat.py
Normal file
43
scripts/benchmark-api-heartbeat.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from time import sleep
|
||||
import cProfile
|
||||
import pstats
|
||||
from datetime import timezone as tz
|
||||
from datetime import datetime
|
||||
|
||||
from aw_core.models import Event
|
||||
|
||||
import aw_datastore
|
||||
import aw_server
|
||||
|
||||
|
||||
def benchmark():
|
||||
ds = aw_datastore.Datastore(aw_datastore.storages.PeeweeStorage, testing=True)
|
||||
api = aw_server.api.ServerAPI(ds, testing=True)
|
||||
|
||||
print(api.get_info())
|
||||
|
||||
bucket_id = "test-benchmark"
|
||||
|
||||
try:
|
||||
api.create_bucket(bucket_id, "test", "test", "test")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
print("Benchmarking... this will take 30 seconds")
|
||||
for i in range(120):
|
||||
sleep(0.1)
|
||||
api.heartbeat(
|
||||
bucket_id,
|
||||
Event(timestamp=datetime.now(tz=tz.utc), data={"test": str(int(i))}),
|
||||
pulsetime=0.3,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
f_bench = "benchmark.dat"
|
||||
cProfile.run("benchmark()", f_bench)
|
||||
p = pstats.Stats(f_bench)
|
||||
p.strip_dirs()
|
||||
# p.sort_stats('tottime')
|
||||
p.sort_stats("cumulative")
|
||||
p.print_stats(20)
|
||||
6
scripts/profile-werkzeug-read.py
Normal file
6
scripts/profile-werkzeug-read.py
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import pstats
|
||||
|
||||
p = pstats.Stats("profile.out")
|
||||
p.sort_stats("cumulative").print_stats(100)
|
||||
6
scripts/profile-werkzeug.py
Normal file
6
scripts/profile-werkzeug.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from werkzeug.contrib.profiler import ProfilerMiddleware
|
||||
from aw_server import app
|
||||
|
||||
app.config["PROFILE"] = True
|
||||
app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])
|
||||
app.run(debug=True)
|
||||
Reference in New Issue
Block a user