* Gets the benchmark result of a singular browser-device pairing. * * If benchmarking produces an error, the given browser-device pairing is * retried up to the specific max number of tries. Default is 3. * * @param tabId Indicates browser-device pairing for benchmark * @param triesLeft Number
( tabId, triesLeft, tabIndex = 0, runOneBenchmark = runBrowserStackBenchmark)
| 240 | * performance test |
| 241 | */ |
| 242 | async function getOneBenchmarkResult( |
| 243 | tabId, triesLeft, tabIndex = 0, |
| 244 | runOneBenchmark = runBrowserStackBenchmark) { |
| 245 | // Since karma will throw out `spawn ETXTBSY` error if initiating multiple |
| 246 | // benchmark runners at the same time, adds delays between initiating runners |
| 247 | // to resolve this race condition. |
| 248 | const numFailed = cliArgs.maxTries - triesLeft; |
| 249 | // The delay increase exponentially when benchmark fails. |
| 250 | const delayInitiatingRunnerTimeMs = tabIndex * (3 ** numFailed) * 1000; |
| 251 | await sleep(delayInitiatingRunnerTimeMs); |
| 252 | |
| 253 | triesLeft--; |
| 254 | try { |
| 255 | const result = await runOneBenchmark(tabId); |
| 256 | console.log(`${tabId} benchmark succeeded.`); |
| 257 | return result; |
| 258 | } catch (err) { |
| 259 | // Retries benchmark until resolved or until no retries left |
| 260 | if (triesLeft > 0) { |
| 261 | console.log(`Retrying ${tabId} benchmark. ${triesLeft} tries left...`); |
| 262 | return await getOneBenchmarkResult(tabId, triesLeft, runOneBenchmark); |
| 263 | } else { |
| 264 | console.log(`${tabId} benchmark failed.`); |
| 265 | throw err; |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * Run benchmark for singular browser-device combination. |
no test coverage detected
searching dependent graphs…