Skip to content

Instantly share code, notes, and snippets.

@mysticatea
Created February 7, 2017 04:39
Show Gist options
  • Save mysticatea/fee91a313d8a201764047ee1be18f1e0 to your computer and use it in GitHub Desktop.
Save mysticatea/fee91a313d8a201764047ee1be18f1e0 to your computer and use it in GitHub Desktop.
"use strict";
/* eslint no-console: off */
const fs = require("fs");
const cp = require("child_process");
const TEST_FILE_DATA = JSON.stringify(
Array.from({ length: 1024 }, () => ({
aaa: Math.random(),
bbb: Math.random(),
ccc: Math.random()
})),
null,
4
);
const N = 7;
console.log("started.");
const times = [];
for (let i = 0; i < N; ++i) {
fs.writeFileSync(".test.js", TEST_FILE_DATA);
const start = Date.now();
cp.spawnSync(process.execPath, ["bin/eslint.js", "--fix", "--no-ignore", ".test.js"], { stdio: "ignore" });
const time = Date.now() - start;
times.push(time);
console.log(`[${i + 1}]`, time, "ms");
}
console.log("----------------");
console.log("[#]", times.sort()[N / 2 | 0], "ms");
fs.unlinkSync(".test.js");
@mysticatea
Copy link
Author

A result:

~\Documents\GitHub\eslint [refactor-fix]> node test.js
started.
[1] 1898 ms
[2] 1876 ms
[3] 1862 ms
[4] 1853 ms
[5] 1879 ms
[6] 1871 ms
[7] 1869 ms
----------------
[#] 1871 ms
~\Documents\GitHub\eslint [refactor-fix]> git checkout master
Your branch is up-to-date with 'origin/master'.
Switched to branch 'master'
~\Documents\GitHub\eslint [master ≡]> node test.js
started.
[1] 2406 ms
[2] 2299 ms
[3] 2408 ms
[4] 2367 ms
[5] 2347 ms
[6] 2366 ms
[7] 2363 ms
----------------
[#] 2366 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment