@@ -43,8 +43,9 @@ class AutocannonBenchmarker {
4343}
4444if ( ! result || ! result . requests || ! result . requests . average ) {
4545return undefined ;
46+ } else {
47+ return result . requests . average ;
4648}
47- return result . requests . average ;
4849}
4950}
5051
@@ -76,8 +77,9 @@ class WrkBenchmarker {
7677const throughput = match && + match [ 1 ] ;
7778if ( ! isFinite ( throughput ) ) {
7879return undefined ;
80+ } else {
81+ return throughput ;
7982}
80- return throughput ;
8183}
8284}
8385
@@ -87,20 +89,18 @@ class WrkBenchmarker {
8789 */
8890class TestDoubleBenchmarker {
8991constructor ( type ) {
90- // `type` is the type of benchmarker. Possible values are 'http' and
91- // 'http2'.
92+ // `type` is the type ofbenchmarker. Possible values are 'http' and 'http2'.
9293this . name = `test-double-${ type } ` ;
9394this . executable = path . resolve ( __dirname , '_test-double-benchmarker.js' ) ;
9495this . present = fs . existsSync ( this . executable ) ;
9596this . type = type ;
9697}
9798
9899create ( options ) {
99- const env = {
100+ const env = Object . assign ( {
100101duration : options . duration ,
101102test_url : `http://127.0.0.1:${ options . port } ${ options . path } ` ,
102- ...process . env
103- } ;
103+ } , process . env ) ;
104104
105105const child = child_process . fork ( this . executable ,
106106[ this . type ] ,
@@ -189,14 +189,13 @@ http_benchmarkers.forEach((benchmarker) => {
189189} ) ;
190190
191191exports . run = function ( options , callback ) {
192- options = {
192+ options = Object . assign ( {
193193port : exports . PORT ,
194194path : '/' ,
195195connections : 100 ,
196196duration : 5 ,
197197benchmarker : exports . default_http_benchmarker ,
198- ...options
199- } ;
198+ } , options ) ;
200199if ( ! options . benchmarker ) {
201200callback ( new Error ( 'Could not locate required http benchmarker. See ' +
202201`${ requirementsURL } for further instructions.` ) ) ;
@@ -213,7 +212,6 @@ exports.run = function(options, callback) {
213212'is not installed' ) ) ;
214213return ;
215214}
216- process . env . duration = process . env . duration || options . duration || 5 ;
217215
218216const benchmarker_start = process . hrtime ( ) ;
219217
@@ -222,8 +220,7 @@ exports.run = function(options, callback) {
222220child . stderr . pipe ( process . stderr ) ;
223221
224222let stdout = '' ;
225- child . stdout . setEncoding ( 'utf8' ) ;
226- child . stdout . on ( 'data' , ( chunk ) => stdout += chunk ) ;
223+ child . stdout . on ( 'data' , ( chunk ) => stdout += chunk . toString ( ) ) ;
227224
228225child . once ( 'close' , ( code ) => {
229226const elapsed = process . hrtime ( benchmarker_start ) ;
0 commit comments