Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browserstack benchmark tool] Enable code snippet benchmark #6704

Merged
merged 9 commits into from
Aug 2, 2022

Conversation

Linchenn
Copy link
Collaborator

@Linchenn Linchenn commented Aug 1, 2022

This PR enable code snippet benchmark.

If you have a code snippet and want to benchmark on multiple devices, you could follow the steps:

Step1: Add your code snippet

Open e2e/benchmarks/browserstack-benchmark/benchmark_models.js and update benchmarkCodeSnippet with your code snippet.

Step2: Run the server and benchmark

  1. Follow the step1~3 of Benchmark usage to start your local server.
  2. Select codeSnippet in model name:
    image
  3. Config the browsers and devices and benchmark.

Example usage

This already populates code snippet to benchmark conv2d and got the following results:
image

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

@Linchenn Linchenn requested review from lina128 and pyu10055 August 1, 2022 21:37
Copy link
Collaborator

@lina128 lina128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @Linchenn and @pyu10055)


e2e/benchmarks/browserstack-benchmark/benchmark_models.js line 96 at r1 (raw file):

  const filter = tf.randomUniform([3, 3, 3, 3], 0, 1000);
  const predict = () => {
    /* Please put your code snippet to benchmark here. */

This will require code change to test custom written code snippet, right? In the future, we can consider dynamic load JS file to test custom written code. Just a thought.

Code quote:

* Please put your code snippet to benchmark here. 

Copy link
Collaborator Author

@Linchenn Linchenn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @lina128 and @pyu10055)


e2e/benchmarks/browserstack-benchmark/benchmark_models.js line 96 at r1 (raw file):

Previously, lina128 (Na Li) wrote…

This will require code change to test custom written code snippet, right? In the future, we can consider dynamic load JS file to test custom written code. Just a thought.

Yes, this requires code changes.

Great catch, loading JS file would support users to input code snippet on the UI (users input code snippet (as string) on UI -> the app.js could generate a JS file with the code snippet -> the benchmark_model.js could call functions from the newly generated JS file).

Another way to support inputting code snippet on the UI is that we could generate benchmark_model.js file directly with customized code snippet.

Copy link
Collaborator

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r1, 1 of 1 files at r2, 2 of 2 files at r3, 2 of 2 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @lina128 and @Linchenn)


e2e/benchmarks/browserstack-benchmark/benchmark_models.js line 96 at r1 (raw file):

Previously, Linchenn wrote…

Yes, this requires code changes.

Great catch, loading JS file would support users to input code snippet on the UI (users input code snippet (as string) on UI -> the app.js could generate a JS file with the code snippet -> the benchmark_model.js could call functions from the newly generated JS file).

Another way to support inputting code snippet on the UI is that we could generate benchmark_model.js file directly with customized code snippet.

can we do similar things as our API website, where users can edit and run code snippet?


e2e/benchmarks/browserstack-benchmark/benchmark_models.js line 106 at r3 (raw file):

  };

  // Wramp up.

warm up

Copy link
Collaborator Author

@Linchenn Linchenn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @lina128 and @pyu10055)


e2e/benchmarks/browserstack-benchmark/benchmark_models.js line 96 at r1 (raw file):

Previously, pyu10055 (Ping Yu) wrote…

can we do similar things as our API website, where users can edit and run code snippet?

yes, in the next step, users could edit code snippets for both benchmarking and environment configuring.

I also tried the following codes:

const a = [];
eval('a.push(1)'); // It works and `a` becomes `[1]`;

This means, the codeSnippet-string within in eval function is run under the context of eval. As a result, the 'code snippet' feature could also be introduced to our online local benchmark tool by calling eval.


e2e/benchmarks/browserstack-benchmark/benchmark_models.js line 106 at r3 (raw file):

Previously, pyu10055 (Ping Yu) wrote…

warm up

Done.

@Linchenn Linchenn requested a review from pyu10055 August 2, 2022 22:18
@pyu10055 pyu10055 merged commit e5c138e into tensorflow:master Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants