Skip to content
Permalink
Browse files

Update README.md with benchmark

  • Loading branch information...
marcomontalbano committed Feb 25, 2019
1 parent 75f3f82 commit d3e2c89409ccd2485e0b83e21b3334fef7e777aa
Showing with 13 additions and 12 deletions.
  1. +7 −3 README.md
  2. +6 −9 src/main.rs
@@ -147,13 +147,17 @@ These benchmarks are recorded on a MacBook Pro (15-inch, 2016) having these spec
- 16 GB 2133 MHz LPDDR3

```sh
cargo build --release
hyperfine --warmup 3 './target/release/wa-vs-js-benchmark primes-get_primes 100000'
$ cargo build --release
$ hyperfine --warmup 3 --export-markdown BENCHMARK.md \
'./target/release/wa-vs-js-benchmark primes-get_primes 100000' \
'./target/release/wa-vs-js-benchmark matrix-multiply 500 500'
```

| Command | Mean [s] | Min…Max [s] |
|:---|---:|---:|
| `./target/release/wa-vs-js-benchmark primes-get_primes 100000` | 1.204 ± 0.012 | 1.193…1.235 |
| `./target/release/wa-vs-js-benchmark primes-get_primes 100000` | 1.198 ± 0.006 | 1.191…1.212 |
| `./target/release/wa-vs-js-benchmark matrix-multiply 500 500` | 0.420 ± 0.006 | 0.411…0.432 |


### WebAssembly vs Javascript
@@ -3,21 +3,18 @@ mod libs;
use std::env;

fn main() {
// println!("total primes: {}", rs::primes::get_primes(100000));

let mut args: Vec<String> = env::args().collect();

let _script_path = args.remove(0);
let invoked_fn = args.remove(0);

// println!("Current path is {}", script_path);
// println!("I should invoke '{}({})'", invoked_fn, &args[0]);

let s: String = invoked_fn.into();

match &s[..] {
"primes-get_primes" => Box::new(libs::primes::get_primes(args[0].parse().unwrap())),
"matrix-multiply" => Box::new(libs::matrix::multiply(args[0].parse().unwrap(), args[1].parse().unwrap())),
_ => {Box::new(0)}
let result = match &s[..] {
"primes-get_primes" => libs::primes::get_primes(args[0].parse().unwrap()),
"matrix-multiply" => libs::matrix::multiply(args[0].parse().unwrap(), args[1].parse().unwrap()),
_ => 0
};

println!("Result for \"{}\" is \"{}\".", s, result);
}

0 comments on commit d3e2c89

Please sign in to comment.
You can’t perform that action at this time.