-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
229 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
[package] | ||
name = "underthesea_core" | ||
version = "0.0.4-alpha.6" | ||
version = "0.0.4-alpha.8" | ||
homepage = "https://github.com/undertheseanlp/underthesea/" | ||
repository = "https://github.com/undertheseanlp/underthesea/" | ||
authors = ["Vu Anh <[email protected]>"] | ||
description = "Underthesea Core (fast & fun)" | ||
license = "GPL-3.0" | ||
edition = "2021" | ||
readme = "README.md" | ||
repository = "https://github.com/undertheseanlp/underthesea/" | ||
homepage = "https://github.com/undertheseanlp/underthesea/" | ||
description = "Underthesea Core (fast & fun)" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
exclude = ["rust-toolchain", "target/*", "Cargo.lock", "benches/*.txt"] | ||
|
||
[lib] | ||
name = "underthesea_core" | ||
path = "src/lib.rs" | ||
crate-type = ["cdylib"] | ||
|
||
[[bench]] | ||
name = "lab" | ||
harness = false | ||
|
||
[dependencies] | ||
serde = { version = "1.0", features = [ "derive" ] } | ||
regex = "1" | ||
rayon = "1.5" | ||
|
||
[dependencies.pyo3] | ||
version = "0.15.0" | ||
features = ["extension-module"] | ||
|
||
[lib] | ||
name = "underthesea_core" | ||
crate-type = ["cdylib"] | ||
[dev-dependencies] | ||
criterion = "0.3.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
extern crate rayon; | ||
extern crate criterion; | ||
|
||
use std::time::Duration; | ||
use rayon::prelude::*; | ||
use criterion::*; | ||
|
||
fn fibonacci(n: u32) -> u32 { | ||
match n { | ||
0 => 1, | ||
1 => 1, | ||
_ => fibonacci(n - 1) + fibonacci(n - 2), | ||
} | ||
} | ||
|
||
fn f1() { | ||
let mut arr: [u32; 2] = [10, 100]; | ||
arr.par_iter_mut().map(|n| fibonacci(*n)); | ||
return; | ||
} | ||
|
||
fn f2() { | ||
let mut arr: [u32; 2] = [10, 100]; | ||
arr.map(|n| fibonacci(n)); | ||
return; | ||
} | ||
|
||
|
||
fn criterion_benchmark(c: &mut Criterion){ | ||
let mut group = c.benchmark_group("abc"); | ||
group.bench_function("my-function", |b| b.iter(|| f1())); | ||
group.finish(); | ||
} | ||
|
||
criterion_group! { | ||
name = benches; | ||
config = Criterion::default().sample_size(10); | ||
targets = criterion_benchmark | ||
} | ||
|
||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "underthesea_core" | ||
version = "0.0.4-alpha.6" | ||
version = "0.0.4-alpha.8" | ||
authors = ["Vu Anh <[email protected]>"] | ||
description = "Underthesea Core (fast & fun)" | ||
license = "GPL-3.0" | ||
|
@@ -15,5 +15,4 @@ python = "^3.5" | |
maturin = "==0.9.4" | ||
|
||
[build-system] | ||
requires = ["==0.9.4"] | ||
build-backend = "maturin" |
Oops, something went wrong.