11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common.js'); 41cb0ef41Sopenharmony_ciconst path = require('path'); 51cb0ef41Sopenharmony_ciconst fs = require('fs'); 61cb0ef41Sopenharmony_ciconst file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 91cb0ef41Sopenharmony_ci requests: [100, 1000, 5000], 101cb0ef41Sopenharmony_ci streams: [1, 10, 20, 40, 100, 200], 111cb0ef41Sopenharmony_ci clients: [2], 121cb0ef41Sopenharmony_ci benchmarker: ['test-double-http2'], 131cb0ef41Sopenharmony_ci duration: 5, 141cb0ef41Sopenharmony_ci}, { flags: ['--no-warnings'] }); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_cifunction main({ requests, streams, clients, duration }) { 171cb0ef41Sopenharmony_ci const http2 = require('http2'); 181cb0ef41Sopenharmony_ci const server = http2.createServer(); 191cb0ef41Sopenharmony_ci server.on('stream', (stream) => { 201cb0ef41Sopenharmony_ci const out = fs.createReadStream(file); 211cb0ef41Sopenharmony_ci stream.respond(); 221cb0ef41Sopenharmony_ci out.pipe(stream); 231cb0ef41Sopenharmony_ci stream.on('error', (err) => {}); 241cb0ef41Sopenharmony_ci }); 251cb0ef41Sopenharmony_ci server.listen(0, () => { 261cb0ef41Sopenharmony_ci bench.http({ 271cb0ef41Sopenharmony_ci path: '/', 281cb0ef41Sopenharmony_ci port: server.address().port, 291cb0ef41Sopenharmony_ci requests, 301cb0ef41Sopenharmony_ci maxConcurrentStreams: streams, 311cb0ef41Sopenharmony_ci clients, 321cb0ef41Sopenharmony_ci duration, 331cb0ef41Sopenharmony_ci threads: clients, 341cb0ef41Sopenharmony_ci }, () => { server.close(); }); 351cb0ef41Sopenharmony_ci }); 361cb0ef41Sopenharmony_ci} 37