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

Function runBrowserStackBenchmark

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

* Run benchmark for singular browser-device combination. * * This function utilizes a promise that is fulfilled once the corresponding * result is returned from BrowserStack. * * @param tabId Indicates browser-device pairing for benchmark

(tabId)

Source from the content-addressed store, hash-verified

276 * @param tabId Indicates browser-device pairing for benchmark
277 */
278function runBrowserStackBenchmark(tabId) {
279 return new Promise((resolve, reject) => {
280 const args = ['test'];
281 if (tabId !== 'local') {
282 args.push('--browserstack', `--browsers=${tabId}`);
283 }
284 if (cliArgs.localBuild) {
285 args.push(`--localBuild=${cliArgs.localBuild}`)
286 };
287 if (cliArgs.npmVersion) {
288 args.push(`--npmVersion=${cliArgs.npmVersion}`)
289 };
290
291 const command = `yarn ${args.join(' ')}`;
292 console.log(`Running: ${command}`);
293 execFile('yarn', args, { timeout: 3e5 }, (error, stdout, stderr) => {
294 if (error) {
295 console.log(`\n${error}`);
296 console.log(`stdout: ${stdout}`);
297 if (!cliArgs.cloud) {
298 io.emit(
299 'benchmarkComplete',
300 { tabId, error: `Failed to run ${command}:\n${error}` });
301 }
302 return reject(`Failed to run ${command}:\n${error}`);
303 }
304
305 const errorReg = /.*\<tfjs_error\>(.*)\<\/tfjs_error\>/;
306 const matchedError = stdout.match(errorReg);
307 if (matchedError != null) {
308 if (!cliArgs.cloud) {
309 io.emit('benchmarkComplete', { tabId, error: matchedError[1] });
310 }
311 return reject(matchedError[1]);
312 }
313
314 const resultReg = /.*\<tfjs_benchmark\>(.*)\<\/tfjs_benchmark\>/;
315 const matchedResult = stdout.match(resultReg);
316 if (matchedResult != null) {
317 const benchmarkResult = JSON.parse(matchedResult[1]);
318 benchmarkResult.tabId = tabId;
319 if (!cliArgs.cloud) {
320 io.emit('benchmarkComplete', benchmarkResult)
321 };
322 return resolve(benchmarkResult);
323 }
324
325 const errorMessage = 'Did not find benchmark results from the logs ' +
326 'of the benchmark test (benchmark_models.js).';
327 if (!cliArgs.cloud) {
328 io.emit('benchmarkComplete', { error: errorMessage })
329 };
330 return reject(errorMessage);
331 });
332 });
333}
334
335/**

Callers

nothing calls this directly

Calls 3

joinMethod · 0.80
logMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…