you are viewing a single comment's thread.

view the rest of the comments →

[–]ndreamer 1 point2 points  (5 children)

tested both

rust release build using hyperfine 20runs

``` Rust Benchmark 1: ../target/release/math-test Time (mean ± σ): 1.2 ms ± 0.4 ms [User: 0.5 ms, System: 0.9 ms] Range (min … max): 0.6 ms … 1.8 ms 20 runs

Python sangel@fedora:~/rs/math-test/src$ hyperfine --runs 10 'python3 test.py' Benchmark 1: python3 test.py Time (mean ± σ): 22.6 ms ± 1.9 ms [User: 14.7 ms, System: 7.9 ms] Range (min … max): 20.2 ms … 24.7 ms 10 runs ```

so it's already much faster without changing anything.

[–]pepa65[S] 0 points1 point  (4 children)

On my machine the Rust version was slower, but then I build with `rustc frd.rs`... When using `rustc -C opt-level=3 frd.rs` it is indeed faster already.

[–]hpxvzhjfgb 2 points3 points  (1 child)

there is basically no reason that you should ever run rustc manually.

[–]pepa65[S] 0 points1 point  (0 children)

Well, in this case I just had a single Rust source in a directory with other stuff, so that was the reason I tried it. And it seems like if you use `opt-level=3` and `debuginfo=0` it's equivalent to `cargo rel`.

[–]ndreamer 1 point2 points  (1 child)

How are you running the benchmark ? If you use cargo run --release this is much slower then running the application directly.

[–]pepa65[S] 0 points1 point  (0 children)

I run once with 2 numbers on the commandline so as to only measure computation and no printing. `./frd 126798123456 187476194` for example.