-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e/heaptrack) set max client to 10K
- Loading branch information
Showing
8 changed files
with
231 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
*.gz | ||
client/node_modules | ||
memory_usage.svg | ||
node_modules | ||
memory_usage.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { io } from "socket.io-client"; | ||
|
||
const URL = process.env.URL || "http://localhost:3000"; | ||
const MAX_CLIENTS = 5000; | ||
const POLLING_PERCENTAGE = 0.05; | ||
const CLIENT_CREATION_INTERVAL_IN_MS = 1; | ||
const EMIT_INTERVAL_IN_MS = 1000; | ||
|
||
let clientCount = 0; | ||
let lastReport = new Date().getTime(); | ||
let packetsSinceLastReport = 0; | ||
|
||
const createClient = () => { | ||
// for demonstration purposes, some clients stay stuck in HTTP long-polling | ||
const transports = | ||
Math.random() < POLLING_PERCENTAGE ? ["polling"] : ["polling", "websocket"]; | ||
|
||
const socket = io(URL, { | ||
transports, | ||
}); | ||
|
||
setInterval(() => { | ||
socket.emit("ping"); | ||
}, EMIT_INTERVAL_IN_MS); | ||
|
||
socket.on("pong", () => { | ||
packetsSinceLastReport++; | ||
}); | ||
|
||
socket.on("disconnect", (reason) => { | ||
console.log(`disconnect due to ${reason}`); | ||
}); | ||
|
||
if (++clientCount < MAX_CLIENTS) { | ||
setTimeout(createClient, CLIENT_CREATION_INTERVAL_IN_MS); | ||
} | ||
}; | ||
|
||
createClient(); | ||
|
||
const printReport = () => { | ||
const now = new Date().getTime(); | ||
const durationSinceLastReport = (now - lastReport) / 1000; | ||
const packetsPerSeconds = ( | ||
packetsSinceLastReport / durationSinceLastReport | ||
).toFixed(2); | ||
|
||
console.log( | ||
`client count: ${clientCount} ; average packets received per second: ${packetsPerSeconds}`, | ||
); | ||
|
||
packetsSinceLastReport = 0; | ||
lastReport = now; | ||
}; | ||
|
||
setInterval(printReport, 5000); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "heaptrack-bench", | ||
"type": "module", | ||
"dependencies": { | ||
"socket.io-client": "^4.8.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^22.10.10" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters