1 // When calling .end(buffer) right away, this triggers a "hot path"
2 // optimization in http.js, to avoid an extra write call.
4 // However, the overhead of copying a large buffer is higher than
5 // the overhead of an extra write() call, so the hot path was not
6 // always as hot as it could be.
8 // Verify that our assumptions are valid.
10 var common = require('../common.js');
11 var PORT = common.PORT;
13 var bench = common.createBenchmark(main, {
14 type: ['asc', 'utf', 'buf'],
15 kb: [64, 128, 256, 1024],
17 method: ['write', 'end']
21 http = require('http');
23 var len = conf.kb * 1024;
26 chunk = new Buffer(len);
31 chunk = new Array(len / 2 + 1).join('ΓΌ');
34 chunk = new Array(len + 1).join('a');
47 var method = conf.method === 'write' ? write : end;
48 var args = ['-d', '10s', '-t', 8, '-c', conf.c];
50 var server = http.createServer(function(req, res) {
54 server.listen(common.PORT, function() {
55 bench.http('/', args, function() {