diff --git a/Cargo.toml b/Cargo.toml index 8cf8c32..26b34d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hpx-rs" version = "0.1.0" -authors = ["Shreyas Atre ", "Dikshant ", "Dikshant "] edition = "2021" readme = "README.md" repository = "https://github.com/STEllAR-GROUP/hpx-rs" @@ -16,5 +16,12 @@ publish = false [dependencies] hpx-sys = { path = "hpx-sys", version = "0.1.0" } +[dev-dependencies] +criterion = "0.3" + +[[bench]] +name = "cpy_bench" +harness = false + [workspace] members = [] diff --git a/benches/cpy_bench.rs b/benches/cpy_bench.rs new file mode 100644 index 0000000..65ed262 --- /dev/null +++ b/benches/cpy_bench.rs @@ -0,0 +1,24 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use hpx_sys::{copy_vector, create_c_args, ffi}; +use std::os::raw::c_char; + +fn benchmark_hpx_copy(c: &mut Criterion) { + c.bench_function("hpx::copy rust benchmark for 1M elements", |b| { + b.iter(|| { + let (argc, mut argv) = create_c_args(&["benchmark_hpx_copy"]); + + let hpx_main = |_argc: i32, _argv: *mut *mut c_char| -> i32 { + let src = vec![1; 1_000_000]; + let _result = copy_vector(black_box(&src)); + ffi::finalize() + }; + + unsafe { + let _result = ffi::init(hpx_main, argc, argv.as_mut_ptr()); + } + }) + }); +} + +criterion_group!(benches, benchmark_hpx_copy); +criterion_main!(benches);