diff options
author | Andreas Madsen <amwebdk@gmail.com> | 2016-02-01 13:30:00 +0300 |
---|---|---|
committer | Andreas Madsen <amwebdk@gmail.com> | 2016-07-26 14:21:39 +0300 |
commit | f99471b2ae147fbb072223be62e9100862379dc8 (patch) | |
tree | 9ba2bd15230ccbd74a55f1c98dceb7e72ce76426 /benchmark/http/http_server_for_chunky_client.js | |
parent | 0f9bfaa7c51bb5f4910ddf068ed89b1bdf35e7d5 (diff) |
benchmark: refactor to use process.send
This removes the need for parsing stdout from the benchmarks. If the
process wasn't executed by fork, it will just print like it used to.
This also fixes the parsing of CLI arguments, by inferring the type
from the options object instead of the value content.
Only two benchmarks had to be changed:
* http/http_server_for_chunky_client.js this previously used a spawn
now it uses a fork and relays the messages using common.sendResult.
* misc/v8-bench.js this utilized that v8/benchmark/run.js called
global.print and reformatted the input. It now interfaces directly
with the benchmark runner global.BenchmarkSuite.
PR-URL: https://github.com/nodejs/node/pull/7094
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'benchmark/http/http_server_for_chunky_client.js')
-rw-r--r-- | benchmark/http/http_server_for_chunky_client.js | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/benchmark/http/http_server_for_chunky_client.js b/benchmark/http/http_server_for_chunky_client.js index d85e15bcbed..fade895aa07 100644 --- a/benchmark/http/http_server_for_chunky_client.js +++ b/benchmark/http/http_server_for_chunky_client.js @@ -3,8 +3,8 @@ var path = require('path'); var http = require('http'); var fs = require('fs'); -var spawn = require('child_process').spawn; -require('../common.js'); +var fork = require('child_process').fork; +var common = require('../common.js'); var test = require('../../test/common.js'); var pep = path.dirname(process.argv[1]) + '/_chunky_http_client.js'; var PIPE = test.PIPE; @@ -30,25 +30,10 @@ server.on('error', function(err) { throw new Error('server error: ' + err); }); -try { - var child; - - server.listen(PIPE); - - child = spawn(process.execPath, [pep], { }); - - child.on('error', function(err) { - throw new Error('spawn error: ' + err); - }); - - child.stdout.pipe(process.stdout); - child.stderr.pipe(process.stderr); - - child.on('close', function(exitCode) { - server.close(); - }); - -} catch (e) { - throw new Error('error: ' + e); -} +server.listen(PIPE); +var child = fork(pep, process.argv.slice(2)); +child.on('message', common.sendResult); +child.on('close', function() { + server.close(); +}); |