MCPcopy Create free account
hub / github.com/tensorflow/tfjs / getOneBenchmarkResult

Function getOneBenchmarkResult

e2e/benchmarks/browserstack-benchmark/app.js:242–268  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

240 * performance test
241 */
242async 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.

Callers 1

app_node_test.jsFile · 0.85

Calls 2

sleepFunction · 0.70
logMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…