Skip to content

Commit

Permalink
Fixing benchmark.js for non-Windows environments
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Jan 6, 2021
1 parent 4d00c88 commit 3934725
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions benchmark.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const path = require("path"),
const {join} = require("path"),
{platform} = require("os"),
{readdir} = require("fs").promises,
{spawn} = require("child_process");

Expand All @@ -26,15 +27,16 @@ function shell (arg = "") {
}

(async function () {
const apath = path.join("node_modules", "autocannon", "autocannon.js"),
cpath = path.join("node_modules", "concurrently", "bin", "concurrently.js"),
fpath = path.join(__dirname, "benchmarks"),
const apath = join("node_modules", "autocannon", "autocannon.js"),
cpath = join("node_modules", "concurrently", "bin", "concurrently.js"),
fpath = join(__dirname, "benchmarks"),
files = await readdir(fpath),
sep = platform() === "win32" ? "\\" : "/",
result = [];

for (const file of files) {
try {
const stdout = await shell(`node ${cpath} -k --success first \"node benchmarks\\${file}\" \"node ${apath} -c 100 -d 40 -p 10 localhost:8000\"`);
const stdout = await shell(`node ${cpath} -k --success first \"node benchmarks${sep}${file}\" \"node ${apath} -c 100 -d 40 -p 10 localhost:8000\"`);

result.push({file: file.replace(".js", ""), stdout});
} catch (err) {
Expand Down

0 comments on commit 3934725

Please sign in to comment.