Skip to content

Commit

Permalink
misc: added wasm benchmarks sources
Browse files Browse the repository at this point in the history
  • Loading branch information
baszalmstra committed Mar 31, 2020
1 parent 4af343c commit 22b9352
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/mun_runtime/benches/wasm-sources/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkg/
2 changes: 2 additions & 0 deletions crates/mun_runtime/benches/wasm-sources/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[workspace]
members=["fibonacci", "empty"]
14 changes: 14 additions & 0 deletions crates/mun_runtime/benches/wasm-sources/empty/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "empty-wasm"
version = "0.1.0"
authors = ["The Mun Team <[email protected]>"]
edition = "2018"
homepage = "https://mun-lang.org"
repository = "https://github.com/mun-lang/mun"
license = "MIT OR Apache-2.0"

[lib]
crate-type = ["cdylib"]

[dependencies]
wasm-bindgen = "0.2"
1 change: 1 addition & 0 deletions crates/mun_runtime/benches/wasm-sources/empty/LICENSE-MIT
8 changes: 8 additions & 0 deletions crates/mun_runtime/benches/wasm-sources/empty/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extern crate wasm_bindgen;

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn empty(n: isize) -> isize {
n
}
14 changes: 14 additions & 0 deletions crates/mun_runtime/benches/wasm-sources/fibonacci/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "fibonacci-wasm"
version = "0.1.0"
authors = ["The Mun Team <[email protected]>"]
edition = "2018"
homepage = "https://mun-lang.org"
repository = "https://github.com/mun-lang/mun"
license = "MIT OR Apache-2.0"

[lib]
crate-type = ["cdylib"]

[dependencies]
wasm-bindgen = "0.2"
23 changes: 23 additions & 0 deletions crates/mun_runtime/benches/wasm-sources/fibonacci/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
extern crate wasm_bindgen;

use wasm_bindgen::prelude::*;

fn fibonacci(n: isize) -> isize {
let mut a = 0;
let mut b = 1;
let mut i = 1;
loop {
if i > n {
return a;
}
let sum = a + b;
a = b;
b = sum;
i += 1;
}
}

#[wasm_bindgen]
pub fn main(n: isize) -> isize {
fibonacci(n)
}

0 comments on commit 22b9352

Please sign in to comment.