1 // Measure the time it takes for the HTTP client to send a request body.
3 var common = require('../common.js');
4 var http = require('http');
6 var bench = common.createBenchmark(main, {
8 type: ['asc', 'utf', 'buf'],
9 bytes: [32, 256, 1024],
10 method: ['write', 'end '] // two spaces added to line up each row
15 var len = +conf.bytes;
21 chunk = new Buffer(len);
26 chunk = new Array(len / 2 + 1).join('ΓΌ');
29 chunk = new Array(len + 1).join('a');
35 headers: { 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked' },
36 agent: new http.Agent({ maxSockets: 1 }),
43 var server = http.createServer(function(req, res) {
46 server.listen(options.port, options.host, function() {
47 setTimeout(done, dur * 1000);
53 var req = http.request(options, function(res) {
55 pummel(); // Line up next request.
58 if (conf.method === 'write') {
59 req.write(chunk, encoding);
62 req.end(chunk, encoding);