(options)
| 67 | } |
| 68 | |
| 69 | create(options) { |
| 70 | const duration = typeof options.duration === 'number' ? |
| 71 | Math.max(options.duration, 1) : |
| 72 | options.duration; |
| 73 | const scheme = options.scheme || 'http'; |
| 74 | const args = [ |
| 75 | '-d', duration, |
| 76 | '-c', options.connections, |
| 77 | '-t', Math.min(options.connections, require('os').availableParallelism() || 8), |
| 78 | `${scheme}://127.0.0.1:${options.port}${options.path}`, |
| 79 | ]; |
| 80 | for (const field in options.headers) { |
| 81 | args.push('-H', `${field}: ${options.headers[field]}`); |
| 82 | } |
| 83 | const child = child_process.spawn(this.executable, args); |
| 84 | return child; |
| 85 | } |
| 86 | |
| 87 | processResults(output) { |
| 88 | const throughputRe = /Requests\/sec:[ \t]+([0-9.]+)/; |
no test coverage detected