Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance benchmark for copy: rust #8

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "hpx-rs"
version = "0.1.0"
authors = ["Shreyas Atre <[email protected]>", "Dikshant <[email protected]"]
authors = ["Shreyas Atre <[email protected]>", "Dikshant <[email protected]>"]
edition = "2021"
readme = "README.md"
repository = "https://github.com/STEllAR-GROUP/hpx-rs"
Expand All @@ -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 = []
24 changes: 24 additions & 0 deletions benches/cpy_bench.rs
Original file line number Diff line number Diff line change
@@ -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);
Loading