-
-
Notifications
You must be signed in to change notification settings - Fork 673
feat(examples/n-body) Fix and improve the Rust example #527
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
Conversation
This patch first updates the documentation to compile the Rust example. Then this patch updates the Rust code, since `panic_implementation` is a deprecated feature. Also `extern` is similar to `extern "C"`. Less code is always better. Finally, this patch compiles and optimises the Rust Wasm binary file (with a simple `wasm-gc` run). The final binary size is 1.4Kb.
@@ -9,4 +9,4 @@ crate-type = ["cdylib"] | |||
|
|||
[profile.release] | |||
lto = true | |||
opt-level = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should stay '3' instead 's' because AS also using -O3
so for better comparison they should have same opt levels
@@ -42,6 +42,6 @@ Benchmark | |||
| **AssemblyScript WASM** | **2901** | **2** | | |||
| AssemblyScript ASMJS | 3720 | 19* | | |||
| JavaScript | 2716 | 5* | | |||
| Rust WASM | 2883 | 13 | | |||
| Rust WASM | 2883 | 1.4* | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust doesn't produce js glue code in current case so mark "*" is unnecessary
@@ -1,7 +1,7 @@ | |||
### Build | |||
|
|||
```bash | |||
cargo build --release --target=wasm32-unknown-unknown | |||
cargo +nightly build --release --target wasm32-unknown-unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's nice. I'm using nightly by default and totally forgot that others use stable or beta by default.
Thanks! Close to favour #528 |
Why closing the PR? I would have appreciated to update the PR myself. |
This patch first updates the documentation to compile the Rust example.
Then this patch updates the Rust code, since
panic_implementation
isa deprecated feature. Also
extern
is similar toextern "C"
. Lesscode is always better.
Finally, this patch compiles and optimises the Rust Wasm binary file
(with a simple
wasm-gc
run). The final binary size is 1.4Kb.I let you run the benchmark if necessary. I don't have the same setup so results will be too different.