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