Created
August 30, 2016 13:28
-
-
Save fengmk2/1634043ec1d40e09b53197b817411131 to your computer and use it in GitHub Desktop.
set header benchmark
This file contains hidden or 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
'use strict'; | |
const OutgoingMessage = require('http').OutgoingMessage; | |
'use strict'; | |
const Benchmark = require('benchmark'); | |
const benchmarks = require('beautify-benchmark'); | |
const suite = new Benchmark.Suite(); | |
suite | |
.add('setHeader() normal', () => { | |
const res = new OutgoingMessage(); | |
res.setHeader('X-Frame-Options1', 'X-Frame-Options1 value'); | |
res.setHeader('X-Frame-Options2', 'X-Frame-Options2 value'); | |
res.setHeader('X-Frame-Options3', 'X-Frame-Options3 value'); | |
}) | |
.add('setHeader() lower case', () => { | |
const res = new OutgoingMessage(); | |
res.setHeader('x-frame-options1', 'X-Frame-Options1 value'); | |
res.setHeader('x-frame-options2', 'X-Frame-Options2 value'); | |
res.setHeader('x-frame-options3', 'X-Frame-Options3 value'); | |
}) | |
.on('cycle', event => { | |
benchmarks.add(event.target); | |
}) | |
.on('start', event => { | |
console.log('\n res.setHeader() Benchmark\n node version: %s, date: %s\n Starting...', | |
process.version, Date()); | |
}) | |
.on('complete', () => { | |
benchmarks.log(); | |
}) | |
.run({ 'async': false }); |
Author
fengmk2
commented
Aug 30, 2016
var key = name.toLowerCase();
this._headers[key] = value;
this._headerNames[key] = name;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment