mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
* less leaky * async readfile * Update types.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
35 lines
856 B
JavaScript
Generated
35 lines
856 B
JavaScript
Generated
import { heapStats } from "bun:jsc";
|
|
|
|
const { SERVER } = process.env;
|
|
|
|
if (typeof SERVER === "undefined" || !SERVER?.length) {
|
|
throw new Error("SERVER environment variable is not set");
|
|
}
|
|
|
|
const COUNT = parseInt(process.env.COUNT || "200", 10);
|
|
await (async function runAll() {
|
|
var fetches = new Array(COUNT);
|
|
let i = 0;
|
|
while (i < Math.max(COUNT - 32, 0)) {
|
|
for (let j = 0; j < 32; j++) {
|
|
fetches.push(fetch(SERVER));
|
|
}
|
|
await Promise.all(fetches);
|
|
fetches.length = 0;
|
|
i += 32;
|
|
}
|
|
|
|
while (i++ < COUNT) {
|
|
fetches.push(fetch(SERVER));
|
|
}
|
|
|
|
await Promise.all(fetches);
|
|
fetches.length = 0;
|
|
fetches = [];
|
|
})();
|
|
await Bun.sleep(10);
|
|
Bun.gc(true);
|
|
if ((heapStats().objectTypeCounts.Response ?? 0) > 1 + ((COUNT / 2) | 0)) {
|
|
throw new Error("Too many Response objects: " + heapStats().objectTypeCounts.Response);
|
|
}
|