-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This bunch of commits help me improve the performance of a http2 server by 8-10%. The benchmarks reports several 1-2% improvements in various areas. PR-URL: #25567 Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
5 changed files
with
83 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
requests: [100, 1000, 5000], | ||
streams: [1, 10, 20, 40, 100, 200], | ||
clients: [2], | ||
benchmarker: ['h2load'] | ||
}, { flags: ['--no-warnings'] }); | ||
|
||
function main({ requests, streams, clients }) { | ||
const http2 = require('http2'); | ||
const server = http2.createServer(); | ||
server.on('request', (req, res) => { | ||
const out = fs.createReadStream(file); | ||
res.setHeader('content-type', 'text/html'); | ||
out.pipe(res); | ||
out.on('error', (err) => { | ||
res.destroy(); | ||
}); | ||
}); | ||
server.listen(common.PORT, () => { | ||
bench.http({ | ||
path: '/', | ||
requests, | ||
maxConcurrentStreams: streams, | ||
clients, | ||
threads: clients | ||
}, () => { server.close(); }); | ||
}); | ||
} |
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