- Download this as ZIP
- Run
node process-bench.js "node 1.js"
- Run
node process-bench.js "npm start"
- Run
node process-bench.js "yarn start"
NPM YARN NODE executing start time
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
console.log(1); |
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
{ | |
"name": "start-time-demo", | |
"version": "2.0.0", | |
"main": "1.js", | |
"scripts": { | |
"start": "node 1.js" | |
}, | |
"license": "MIT" | |
} |
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
const {exec} = require("child_process"); | |
const command = process.argv[2]; | |
if (!command) { | |
console.log("[error] process.argv[2] is empty"); | |
} | |
const startTime = Date.now(); | |
const proc = exec(command); | |
console.log(`[exec start][${command}]`, Date.now() - startTime); | |
proc.stdout.on("data", data => { | |
console.log("[data]", Date.now() - startTime); | |
console.log(data); | |
}); | |
proc.stdout.on("end", () => { | |
console.log("[exec end]", Date.now() - startTime); | |
}); | |
proc.on("error", e => console.log("[error][stdout]", e)); | |
proc.stdout.on("error", e => console.log("[error]", e)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment