Skip to content

Commit

Permalink
dashboard: update the rate information every 1000ms instead of every …
Browse files Browse the repository at this point in the history
…batchTimeWhenVisible

This reduces CPU usage.
  • Loading branch information
ivan committed Jun 9, 2023
1 parent 2c66a86 commit 4bea178
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dashboard/assets/scripts/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,8 @@ class Dashboard {
const finishSetup = () => {
byId("meta-info").innerHTML = "";

const keepReadings = Math.round(3000 / batchTimeWhenVisible);
const rateRefreshInterval = 1000;
const keepReadings = Math.round(5000 / rateRefreshInterval);
const messagesRate = new RateTracker(keepReadings);
const bytesRate = new RateTracker(keepReadings);
let newItemsReceived = 0;
Expand All @@ -1063,7 +1064,7 @@ class Dashboard {
byId("meta-info").textContent = `WS:
${String(msgPerSec).padStart(3, "0")} msg/s,
${String(kbPerSec).padStart(3, "0")} KB/s`;
}, batchTimeWhenVisible);
}, rateRefreshInterval);

this.queue = new BatchingQueue(
(queue) => {
Expand Down

0 comments on commit 4bea178

Please sign in to comment.