diff --git a/Cargo.toml b/Cargo.toml index f9de563..8173a66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,17 +1,10 @@ [package] name = "remote-hdt" -version = "0.1.0" +version = "0.0.1" edition = "2021" [dependencies] zarr3 = { git = "https://github.com/clbarnes/zarr3-rs.git" } rdf-rs = { path = "./rdf-rs" } rio_api = "0.8.4" -ndarray = "0.15.6" - -[dev-dependencies] -criterion = "0.5.1" - -[[bench]] -name = "lubm" -harness = false \ No newline at end of file +ndarray = "0.15.6" \ No newline at end of file diff --git a/benches/lubm/main.rs b/benches/lubm/main.rs deleted file mode 100644 index 250d316..0000000 --- a/benches/lubm/main.rs +++ /dev/null @@ -1,20 +0,0 @@ -use criterion::{criterion_group, criterion_main, Criterion}; -use remote_hdt::remote_hdt::RemoteHDTBuilder; - -const BENCHMARKS: [&str; 1] = ["lubm1000"]; - -fn lubm_benchmark(c: &mut Criterion) { - c.bench_function(format!("{}", BENCHMARKS[0]).as_str(), |b| { - b.iter(|| { - // Code to benchmark - let _ = RemoteHDTBuilder::new(format!("{}.zarr", BENCHMARKS[0]).as_str()) - .rdf_path(format!("benches/lubm/{}.nt", BENCHMARKS[0]).as_str()) - .array_name("array_name") - .build() - .serialize(); - }) - }); -} - -criterion_group!(benches, lubm_benchmark); -criterion_main!(benches); diff --git a/examples/bench.rs b/examples/bench.rs new file mode 100644 index 0000000..fe7fdbb --- /dev/null +++ b/examples/bench.rs @@ -0,0 +1,16 @@ +use remote_hdt::remote_hdt::RemoteHDTBuilder; +use std::time::Instant; + +const BENCHMARKS: [&str; 1] = ["10-lubm"]; + +fn main() { + let before = Instant::now(); + + let _ = RemoteHDTBuilder::new(format!("{}.zarr", BENCHMARKS[0]).as_str()) + .rdf_path(format!("../lubm-uba-improved/out/{}.ttl", BENCHMARKS[0]).as_str()) + .array_name("array_name") + .build() + .serialize(); + + println!("Elapsed time: {:.2?}", before.elapsed()) +} diff --git a/src/remote_hdt.rs b/src/remote_hdt.rs index 762fb76..57bfd4a 100644 --- a/src/remote_hdt.rs +++ b/src/remote_hdt.rs @@ -281,6 +281,9 @@ impl ReferenceSystem { // desired mechanism let mut v = Vec::<(usize, usize, usize, u8)>::new(); + // Could this be improved using a multithreading approach? If we use + // rayon the solution would be possibly faster and the implementation + // details wouldn't vary as much for (i, outer) in array.outer_iter().enumerate() { for j in 0..outer.shape()[0] { for k in 0..outer.shape()[1] { @@ -300,6 +303,7 @@ impl ReferenceSystem { let mut reshaped_array = ArcArray3::zeros(other.shape(&domain)); + // Same here... Using rayon would be desirable for (s, p, o, value) in v { match other { ReferenceSystem::SPO => reshaped_array[[s, p, o]] = value, @@ -425,6 +429,8 @@ impl<'a> RemoteHDT<'a> { // the provided values (second vector). What's more, an offset can be set; // that is, we can insert the created array with and X and Y shift. Lastly, // the region is written provided the aforementioned data and offset + // TODO: use rayon for a multithreaded approach + // TODO: use a better method than nested loops let data = match ArcArrayD::from_shape_vec(self.reference_system.shape(domain).to_vec(), { let mut v = Vec::::new(); for subject in &subjects { @@ -454,7 +460,7 @@ impl<'a> RemoteHDT<'a> { return Err(String::from("Error writing to the Array")); }; - // Ok(()) + // Ok(self) // ========================================================================= // TODO: remove this because it's just for debug purposes