This repository has been archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 95bbb68 as of 2017-08-13. This is an automatically created merge. For any problems please contact @kunalspathak.
- Loading branch information
Showing
26 changed files
with
1,861 additions
and
1,597 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,47 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
const PORT = common.PORT; | ||
|
||
var bench = common.createBenchmark(main, { | ||
n: [1e3], | ||
nheaders: [100, 1000], | ||
}, { flags: ['--expose-http2', '--no-warnings'] }); | ||
|
||
function main(conf) { | ||
const n = +conf.n; | ||
const nheaders = +conf.nheaders; | ||
const http2 = require('http2'); | ||
const server = http2.createServer(); | ||
|
||
const headersObject = { ':path': '/' }; | ||
for (var i = 0; i < nheaders; i++) { | ||
headersObject[`foo${i}`] = `some header value ${i}`; | ||
} | ||
|
||
server.on('stream', (stream) => { | ||
stream.respond(); | ||
stream.end('Hi!'); | ||
}); | ||
server.listen(PORT, () => { | ||
const client = http2.connect(`http://localhost:${PORT}/`); | ||
|
||
function doRequest(remaining) { | ||
const req = client.request(headersObject); | ||
req.end(); | ||
req.on('data', () => {}); | ||
req.on('end', () => { | ||
if (remaining > 0) { | ||
doRequest(remaining - 1); | ||
} else { | ||
bench.end(n); | ||
server.close(); | ||
client.destroy(); | ||
} | ||
}); | ||
} | ||
|
||
bench.start(); | ||
doRequest(n); | ||
}); | ||
} |
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,39 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const util = require('util'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
n: [1e2], | ||
len: [1e5], | ||
type: [ | ||
'denseArray', | ||
'sparseArray', | ||
'mixedArray' | ||
] | ||
}); | ||
|
||
function main(conf) { | ||
const { n, len, type } = conf; | ||
var arr = Array(len); | ||
var i; | ||
|
||
switch (type) { | ||
case 'denseArray': | ||
arr = arr.fill(0); | ||
break; | ||
case 'sparseArray': | ||
break; | ||
case 'mixedArray': | ||
for (i = 0; i < n; i += 2) | ||
arr[i] = i; | ||
break; | ||
default: | ||
throw new Error(`Unsupported type ${type}`); | ||
} | ||
bench.start(); | ||
for (i = 0; i < n; i++) { | ||
util.inspect(arr); | ||
} | ||
bench.end(n); | ||
} |
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
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
Oops, something went wrong.