-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: improve performance for incoming headers
PR-URL: #26041 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
- Loading branch information
Showing
3 changed files
with
124 additions
and
118 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
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 http = require('http'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
// unicode confuses ab on os x. | ||
c: [50, 500], | ||
headerDuplicates: [0, 5, 20] | ||
}); | ||
|
||
function main({ c, headerDuplicates }) { | ||
const server = http.createServer((req, res) => { | ||
res.end(); | ||
}); | ||
|
||
server.listen(common.PORT, () => { | ||
const headers = { | ||
'Content-Type': 'text/plain', | ||
'Accept': 'text/plain', | ||
'User-Agent': 'nodejs-benchmark', | ||
'Date': new Date().toString(), | ||
'Cache-Control': 'no-cache' | ||
}; | ||
for (let i = 0; i < headerDuplicates; i++) { | ||
headers[`foo${i}`] = `some header value ${i}`; | ||
} | ||
bench.http({ | ||
path: '/', | ||
connections: c, | ||
headers | ||
}, () => { | ||
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