This repository has been archived by the owner on Jul 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #180 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
Showing
5 changed files
with
150 additions
and
1 deletion.
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
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,43 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
const PORT = common.PORT; | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html'); | ||
|
||
var bench = common.createBenchmark(main, { | ||
requests: [100, 1000, 10000, 100000, 1000000], | ||
streams: [100, 200, 1000], | ||
clients: [1, 2] | ||
}, { flags: ['--expose-http2', '--no-warnings'] }); | ||
|
||
function main(conf) { | ||
|
||
fs.open(file, 'r', (err, fd) => { | ||
if (err) | ||
throw err; | ||
|
||
const n = +conf.requests; | ||
const m = +conf.streams; | ||
const c = +conf.clients; | ||
const http2 = require('http2'); | ||
const server = http2.createServer(); | ||
server.on('stream', (stream) => { | ||
stream.respondWithFD(fd); | ||
stream.on('error', (err) => {}); | ||
}); | ||
server.listen(PORT, () => { | ||
bench.http({ | ||
path: '/', | ||
requests: n, | ||
maxConcurrentStreams: m, | ||
clients: c, | ||
threads: c | ||
}, () => 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
const PORT = common.PORT; | ||
|
||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html'); | ||
|
||
var bench = common.createBenchmark(main, { | ||
requests: [100, 1000, 10000, 100000], | ||
streams: [100, 200, 1000], | ||
clients: [1, 2] | ||
}, { flags: ['--expose-http2', '--no-warnings'] }); | ||
|
||
function main(conf) { | ||
const n = +conf.requests; | ||
const m = +conf.streams; | ||
const c = +conf.clients; | ||
const http2 = require('http2'); | ||
const server = http2.createServer(); | ||
server.on('stream', (stream) => { | ||
const out = fs.createReadStream(file); | ||
stream.respond(); | ||
out.pipe(stream); | ||
stream.on('error', (err) => {}); | ||
}); | ||
server.listen(PORT, () => { | ||
bench.http({ | ||
path: '/', | ||
requests: n, | ||
maxConcurrentStreams: m, | ||
clients: c, | ||
threads: c | ||
}, () => { 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