@@ -43,8 +43,9 @@ class AutocannonBenchmarker {
4343 }
4444 if ( ! result || ! result . requests || ! result . requests . average ) {
4545 return undefined ;
46+ } else {
47+ return result . requests . average ;
4648 }
47- return result . requests . average ;
4849 }
4950}
5051
@@ -76,8 +77,9 @@ class WrkBenchmarker {
7677 const throughput = match && + match [ 1 ] ;
7778 if ( ! isFinite ( throughput ) ) {
7879 return undefined ;
80+ } else {
81+ return throughput ;
7982 }
80- return throughput ;
8183 }
8284}
8385
@@ -87,20 +89,18 @@ class WrkBenchmarker {
8789 */
8890class TestDoubleBenchmarker {
8991 constructor ( 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'.
9293 this . name = `test-double-${ type } ` ;
9394 this . executable = path . resolve ( __dirname , '_test-double-benchmarker.js' ) ;
9495 this . present = fs . existsSync ( this . executable ) ;
9596 this . type = type ;
9697 }
9798
9899 create ( options ) {
99- const env = {
100+ const env = Object . assign ( {
100101 duration : options . duration ,
101102 test_url : `http://127.0.0.1:${ options . port } ${ options . path } ` ,
102- ...process . env
103- } ;
103+ } , process . env ) ;
104104
105105 const 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 ( {
193193 port : exports . PORT ,
194194 path : '/' ,
195195 connections : 100 ,
196196 duration : 5 ,
197197 benchmarker : exports . default_http_benchmarker ,
198- ...options
199- } ;
198+ } , options ) ;
200199 if ( ! options . benchmarker ) {
201200 callback ( 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' ) ) ;
214213 return ;
215214 }
216- process . env . duration = process . env . duration || options . duration || 5 ;
217215
218216 const benchmarker_start = process . hrtime ( ) ;
219217
@@ -222,8 +220,7 @@ exports.run = function(options, callback) {
222220 child . stderr . pipe ( process . stderr ) ;
223221
224222 let stdout = '' ;
225- child . stdout . setEncoding ( 'utf8' ) ;
226- child . stdout . on ( 'data' , ( chunk ) => stdout += chunk ) ;
223+ child . stdout . on ( 'data' , ( chunk ) => stdout += chunk . toString ( ) ) ;
227224
228225 child . once ( 'close' , ( code ) => {
229226 const elapsed = process . hrtime ( benchmarker_start ) ;
0 commit comments