colyseus-server-stress-tester/received-packages.js
2022-08-04 09:56:05 +08:00

10 lines
261 B
JavaScript

let lastReceivedAt = new Date();
export let rps = 0;
export let packageCounts = 0;
export const markReceive = () => {
const now = new Date();
rps = (1000 / (now.getTime() - lastReceivedAt.getTime())).toFixed(2);
lastReceivedAt = now;
packageCounts++;
}