colyseus-server-stress-tester/received-packages.js

10 lines
261 B
JavaScript
Raw Normal View History

2022-08-04 09:56:05 +08:00
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++;
}