summaryrefslogtreecommitdiff
path: root/cli/bench/http/deno_http_flash_spawn.js
blob: e5ad73a2e0e4089671fc9a571e7f4a391312d7cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.

if (Deno.build.os !== "linux") {
  throw new Error("SO_REUSEPORT is only supported on Linux");
}

const executable = Deno.execPath();
const path = new URL("./deno_http_flash.js", import.meta.url).pathname;
// single flash instance runs on ~1.8 cores
const cpus = navigator.hardwareConcurrency / 2;
const processes = new Array(cpus);
for (let i = 0; i < cpus; i++) {
  // deno-lint-ignore no-deprecated-deno-api
  const proc = Deno.run({
    cmd: [executable, "run", "-A", "--unstable", path, Deno.args[0]],
  });
  processes.push(proc.status());
}
await Promise.all(processes);