node/benchmark/http/http_server_for_chunky_client.js
Rich Trott 566a1513d1 benchmark: reformat code for clarity
Some of the benchmark code can be a little dense. Not *very* hard to
read but perhaps harder than it needs to be.

These changes (many of them whitespace-only) hopefully improve
readability.

There are also a few cases of `assert.equal()` that are changed to
`assert.strictEqual()`.

PR-URL: https://github.com/nodejs/node/pull/9790
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-11-27 21:51:09 -08:00

43 lines
901 B
JavaScript

'use strict';
var path = require('path');
var http = require('http');
var fs = require('fs');
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;
try {
fs.accessSync(test.tmpDir, fs.F_OK);
} catch (e) {
fs.mkdirSync(test.tmpDir);
}
var server;
try {
fs.unlinkSync(PIPE);
} catch (e) { /* ignore */ }
server = http.createServer(function(req, res) {
var headers = {
'content-type': 'text/plain',
'content-length': '2'
};
res.writeHead(200, headers);
res.end('ok');
});
server.on('error', function(err) {
throw new Error('server error: ' + err);
});
server.listen(PIPE);
var child = fork(pep, process.argv.slice(2));
child.on('message', common.sendResult);
child.on('close', function() {
server.close();
});