| 147 | } |
| 148 | |
| 149 | create(options) { |
| 150 | const args = []; |
| 151 | if (typeof options.requests === 'number') |
| 152 | args.push('-n', options.requests); |
| 153 | if (typeof options.clients === 'number') |
| 154 | args.push('-c', options.clients); |
| 155 | if (typeof options.threads === 'number') |
| 156 | args.push('-t', options.threads); |
| 157 | if (typeof options.maxConcurrentStreams === 'number') |
| 158 | args.push('-m', options.maxConcurrentStreams); |
| 159 | if (typeof options.initialWindowSize === 'number') |
| 160 | args.push('-w', options.initialWindowSize); |
| 161 | if (typeof options.sessionInitialWindowSize === 'number') |
| 162 | args.push('-W', options.sessionInitialWindowSize); |
| 163 | if (typeof options.rate === 'number') |
| 164 | args.push('-r', options.rate); |
| 165 | if (typeof options.ratePeriod === 'number') |
| 166 | args.push(`--rate-period=${options.ratePeriod}`); |
| 167 | if (typeof options.duration === 'number') |
| 168 | args.push('-T', options.duration); |
| 169 | if (typeof options.timeout === 'number') |
| 170 | args.push('-N', options.timeout); |
| 171 | if (typeof options.headerTableSize === 'number') |
| 172 | args.push(`--header-table-size=${options.headerTableSize}`); |
| 173 | if (typeof options.encoderHeaderTableSize === 'number') { |
| 174 | args.push( |
| 175 | `--encoder-header-table-size=${options.encoderHeaderTableSize}`); |
| 176 | } |
| 177 | const scheme = options.scheme || 'http'; |
| 178 | const host = options.host || '127.0.0.1'; |
| 179 | args.push(`${scheme}://${host}:${options.port}${options.path}`); |
| 180 | const child = child_process.spawn(this.executable, args); |
| 181 | return child; |
| 182 | } |
| 183 | |
| 184 | processResults(output) { |
| 185 | const rex = /(\d+\.\d+) req\/s/; |