This repository has been archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2017-06-13 Node.js 8.1.1 (Stable) Release Git-EVTag-v0-SHA512: c78fd6249fcc44b33dcd7f9c661b73e0b5c1015e4649a7cebd0d542d5850365b7f67421d3da42d4e455687a260a549b00c7a208baf1cc631eaab99464eb0332a PR-URL: #299 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com>
- Loading branch information
Showing
75 changed files
with
1,197 additions
and
417 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,42 @@ | ||
'use strict'; | ||
const common = require('../common.js'); | ||
const { exec, execSync } = require('child_process'); | ||
const isWindows = process.platform === 'win32'; | ||
|
||
var messagesLength = [64, 256, 1024, 4096]; | ||
// Windows does not support that long arguments | ||
if (process.platform !== 'win32') | ||
messagesLength.push(32768); | ||
const bench = common.createBenchmark(main, { | ||
// Windows does not support command lines longer than 8191 characters | ||
if (!isWindows) messagesLength.push(32768); | ||
|
||
const bench = common.createBenchmark(childProcessExecStdout, { | ||
len: messagesLength, | ||
dur: [5] | ||
}); | ||
|
||
const child_process = require('child_process'); | ||
const exec = child_process.exec; | ||
function main(conf) { | ||
function childProcessExecStdout(conf) { | ||
bench.start(); | ||
|
||
const dur = +conf.dur; | ||
const maxDuration = conf.dur * 1000; | ||
const len = +conf.len; | ||
|
||
const msg = `"${'.'.repeat(len)}"`; | ||
// eslint-disable-next-line no-unescaped-regexp-dot | ||
msg.match(/./); | ||
const options = {'stdio': ['ignore', 'pipe', 'ignore']}; | ||
const child = exec(`yes ${msg}`, options); | ||
const cmd = `yes "${'.'.repeat(len)}"`; | ||
const child = exec(cmd, { 'stdio': ['ignore', 'pipe', 'ignore'] }); | ||
|
||
var bytes = 0; | ||
child.stdout.on('data', function(msg) { | ||
child.stdout.on('data', (msg) => { | ||
bytes += msg.length; | ||
}); | ||
|
||
setTimeout(function() { | ||
setTimeout(() => { | ||
bench.end(bytes); | ||
if (process.platform === 'win32') { | ||
// Sometimes there's a yes.exe process left hanging around on Windows... | ||
child_process.execSync(`taskkill /f /t /pid ${child.pid}`); | ||
if (isWindows) { | ||
// Sometimes there's a yes.exe process left hanging around on Windows. | ||
try { | ||
execSync(`taskkill /f /t /pid ${child.pid}`); | ||
} catch (_) { | ||
// this is a best effort kill. stderr is piped to parent for tracing. | ||
} | ||
} else { | ||
child.kill(); | ||
} | ||
}, dur * 1000); | ||
}, maxDuration); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
'use strict'; | ||
|
||
const cluster = require('cluster'); | ||
if (cluster.isMaster) { | ||
const common = require('../common.js'); | ||
const bench = common.createBenchmark(main, { | ||
workers: [1], | ||
payload: ['string', 'object'], | ||
sendsPerBroadcast: [1, 10], | ||
n: [1e5] | ||
}); | ||
|
||
function main(conf) { | ||
var n = +conf.n; | ||
var workers = +conf.workers; | ||
var sends = +conf.sendsPerBroadcast; | ||
var expectedPerBroadcast = sends * workers; | ||
var payload; | ||
var readies = 0; | ||
var broadcasts = 0; | ||
var msgCount = 0; | ||
|
||
switch (conf.payload) { | ||
case 'string': | ||
payload = 'hello world!'; | ||
break; | ||
case 'object': | ||
payload = { action: 'pewpewpew', powerLevel: 9001 }; | ||
break; | ||
default: | ||
throw new Error('Unsupported payload type'); | ||
} | ||
|
||
for (var i = 0; i < workers; ++i) | ||
cluster.fork().on('online', onOnline).on('message', onMessage); | ||
|
||
function onOnline(msg) { | ||
if (++readies === workers) { | ||
bench.start(); | ||
broadcast(); | ||
} | ||
} | ||
|
||
function broadcast() { | ||
var id; | ||
if (broadcasts++ === n) { | ||
bench.end(n); | ||
for (id in cluster.workers) | ||
cluster.workers[id].disconnect(); | ||
return; | ||
} | ||
for (id in cluster.workers) { | ||
const worker = cluster.workers[id]; | ||
for (var i = 0; i < sends; ++i) | ||
worker.send(payload); | ||
} | ||
} | ||
|
||
function onMessage(msg) { | ||
if (++msgCount === expectedPerBroadcast) { | ||
msgCount = 0; | ||
broadcast(); | ||
} | ||
} | ||
} | ||
} else { | ||
process.on('message', function(msg) { | ||
process.send(msg); | ||
}); | ||
} |
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
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
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
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
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
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
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
Oops, something went wrong.