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

Performance Benchmarking Tips #173

Open
stevekrouse opened this issue Mar 25, 2022 · 6 comments
Open

Performance Benchmarking Tips #173

stevekrouse opened this issue Mar 25, 2022 · 6 comments
Assignees
Labels
docs Improvements or additions to documentation

Comments

@stevekrouse
Copy link
Contributor

We should create a page in the docs to collect tips for benchmarking performance:

  1. Start by measuring your JS, and confirming that it's slow in a way that Rust/Wasm will be faster in (with rough estimates of how much faster, and a link to a benchmark):

parsing - yes (2.5x faster)
matrix math - yes
generating vertex shaders - yes
dom manipulation - no

When in doubt, ask the Slack if the slowness in your app can be improved by Zaplib before you invest time into writing a port!

  1. Use performance.now in JS & Instant::now() in Rust
  2. Run the tests a couple of times and take an average
  3. Run the wasm tests with the browser devtools closed (open after or use HTML to see results)
@stevekrouse stevekrouse self-assigned this Mar 25, 2022
@stevekrouse stevekrouse moved this from Backlog to Soon in Current work Mar 25, 2022
@stevekrouse stevekrouse moved this to Backlog in Current work Mar 25, 2022
@pankdm
Copy link
Collaborator

pankdm commented Mar 25, 2022

I think Instant::now() won't work in Rust when compiled into wasm. Probably better use zaplib::UniversalInstant::now() instead?

@stevekrouse
Copy link
Contributor Author

Oh damn! That's what I was using... What's the problem with it?

@janpaul123
Copy link
Contributor

Hm it seems like it infers to use UniversalInstant from this: https://github.com/Zaplib/zaplib/pull/166/files#diff-6ab2609914bb3aa54a94aa7d90dc83537e41efed475d85ddbb31ed3e413f5aadR44 I guess since we define and implement an Instant trait for UniversalInstant. We probably shouldn't do that to avoid confusion with std::time::Instant..

@pankdm
Copy link
Collaborator

pankdm commented Mar 25, 2022

Ah, yes! That's quite confusing usage. I suspect if you remove type annotation of UniversalInstant then it won't compile/work anymore - so you are indeed using UniverstalInstant not the typical std::time::Instant.

@janpaul123 janpaul123 added the docs Improvements or additions to documentation label Mar 25, 2022
@stevekrouse
Copy link
Contributor Author

Oh fascinating! It did error and suggested I add that type annotation, so that's how the code ended up in that state.

@stevekrouse
Copy link
Contributor Author

Maybe we link to resources like this https://nnethercote.github.io/perf-book/introduction.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
Status: Soon
Development

No branches or pull requests

3 participants