EgeEken commited on
Commit
919eafa
·
1 Parent(s): d425d15

speed benchmark reset button

Browse files
Files changed (4) hide show
  1. pbc3_benchmark.py +14 -0
  2. server.py +8 -0
  3. static/benchmark.js +10 -0
  4. static/index.html +1 -1
pbc3_benchmark.py CHANGED
@@ -264,6 +264,20 @@ def _run(codecs, n_trials):
264
  _log("benchmark stopped")
265
 
266
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  def results(mp_min=None, mp_max=None):
268
  if not os.path.exists(DB_PATH):
269
  return {"exists": False, "rows": [], "points": []}
 
264
  _log("benchmark stopped")
265
 
266
 
267
+ def reset_pbc():
268
+ if status()["running"]:
269
+ return {"error": "Stop the benchmark before resetting PBC3 rows."}
270
+ if not os.path.exists(DB_PATH):
271
+ return {"ok": True, "deleted": 0}
272
+ con = _connect()
273
+ try:
274
+ cur = con.execute("DELETE FROM results WHERE codec = ?", ("PBC3",))
275
+ con.commit()
276
+ return {"ok": True, "deleted": cur.rowcount}
277
+ finally:
278
+ con.close()
279
+
280
+
281
  def results(mp_min=None, mp_max=None):
282
  if not os.path.exists(DB_PATH):
283
  return {"exists": False, "rows": [], "points": []}
server.py CHANGED
@@ -768,6 +768,14 @@ def benchmark_results(mp_min: float = None, mp_max: float = None):
768
  return pbc3_benchmark.results(mp_min, mp_max)
769
 
770
 
 
 
 
 
 
 
 
 
771
  @app.get("/api/benchmark/download_db")
772
  def benchmark_download_db():
773
  if not os.path.exists(pbc3_benchmark.DB_PATH):
 
768
  return pbc3_benchmark.results(mp_min, mp_max)
769
 
770
 
771
+ @app.post("/api/benchmark/reset_pbc")
772
+ def benchmark_reset_pbc():
773
+ result = pbc3_benchmark.reset_pbc()
774
+ if result.get("error"):
775
+ return JSONResponse(result, status_code=409)
776
+ return result
777
+
778
+
779
  @app.get("/api/benchmark/download_db")
780
  def benchmark_download_db():
781
  if not os.path.exists(pbc3_benchmark.DB_PATH):
static/benchmark.js CHANGED
@@ -44,6 +44,7 @@ window.BenchmarkPage = (function () {
44
  <div class="sw-row">
45
  <label class="sw-btn">Upload benchmark data<input id="bm-upload" type="file" accept=".db" hidden></label>
46
  <button id="bm-download" class="sw-btn">Download benchmark data</button>
 
47
  </div>
48
  <div id="bm-dbmsg" class="sw-muted" style="margin-top:8px"></div>
49
  </div>
@@ -124,6 +125,7 @@ window.BenchmarkPage = (function () {
124
 
125
  $("bm-upload").onchange = (e) => e.target.files[0] && uploadDb(e.target.files[0]);
126
  $("bm-download").onclick = () => window.open("/api/benchmark/download_db", "_blank");
 
127
  $("bm-n").oninput = (e) => $("bm-n-val").textContent = e.target.value;
128
  $("bm-run").onclick = start;
129
  $("bm-stop").onclick = stop;
@@ -174,6 +176,14 @@ window.BenchmarkPage = (function () {
174
  refreshResults();
175
  }
176
 
 
 
 
 
 
 
 
 
177
  function startPolling() { if (!S.poll) S.poll = setInterval(refreshStatus, 2000); }
178
  function stopPolling() { if (S.poll) { clearInterval(S.poll); S.poll = null; } }
179
 
 
44
  <div class="sw-row">
45
  <label class="sw-btn">Upload benchmark data<input id="bm-upload" type="file" accept=".db" hidden></label>
46
  <button id="bm-download" class="sw-btn">Download benchmark data</button>
47
+ <button id="bm-reset-pbc" class="sw-btn danger">Reset PBC3</button>
48
  </div>
49
  <div id="bm-dbmsg" class="sw-muted" style="margin-top:8px"></div>
50
  </div>
 
125
 
126
  $("bm-upload").onchange = (e) => e.target.files[0] && uploadDb(e.target.files[0]);
127
  $("bm-download").onclick = () => window.open("/api/benchmark/download_db", "_blank");
128
+ $("bm-reset-pbc").onclick = resetPbcRows;
129
  $("bm-n").oninput = (e) => $("bm-n-val").textContent = e.target.value;
130
  $("bm-run").onclick = start;
131
  $("bm-stop").onclick = stop;
 
176
  refreshResults();
177
  }
178
 
179
+ async function resetPbcRows() {
180
+ if (!confirm("Reset all PBC3 rows from the benchmark database? Other codec rows will be kept.")) return;
181
+ const r = await fetch("/api/benchmark/reset_pbc", { method: "POST" });
182
+ const d = await r.json();
183
+ $("bm-dbmsg").textContent = d.error || `Deleted ${d.deleted || 0} PBC3 benchmark row(s).`;
184
+ refreshResults();
185
+ }
186
+
187
  function startPolling() { if (!S.poll) S.poll = setInterval(refreshStatus, 2000); }
188
  function stopPolling() { if (S.poll) { clearInterval(S.poll); S.poll = null; } }
189
 
static/index.html CHANGED
@@ -253,7 +253,7 @@
253
  <script src="/app.js?v=20260625a"></script>
254
  <script src="/viewer_magnifier.js?v=20260622b"></script>
255
  <script src="/sweep.js?v=20260622b"></script>
256
- <script src="/benchmark.js?v=20260624e"></script>
257
  <script src="/quick_rd.js?v=20260625d"></script>
258
  <script src="/sweep_runner.js?v=20260624a"></script>
259
  <script src="/train.js?v=20260623a"></script>
 
253
  <script src="/app.js?v=20260625a"></script>
254
  <script src="/viewer_magnifier.js?v=20260622b"></script>
255
  <script src="/sweep.js?v=20260622b"></script>
256
+ <script src="/benchmark.js?v=20260625f"></script>
257
  <script src="/quick_rd.js?v=20260625d"></script>
258
  <script src="/sweep_runner.js?v=20260624a"></script>
259
  <script src="/train.js?v=20260623a"></script>