Skip to content
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
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ all: lint mypy test

.PHONY: clean
clean:
rm -rf `find . -name __pycache__`
rm -f `find . -type f -name '*.py[co]' `
rm -f `find . -type f -name '*~' `
rm -f `find . -type f -name '.*~' `
rm -f `find . -type f -name '*.cpython-*' `
# TODO -> this kinda wipes a lot of stuff in the python environment, maybe we should be more specific
rm -rf `find . -name __pycache__ -not -path "./.venv/*"`
rm -f `find . -type f -name '*.py[co]' -not -path "./.venv/*"`
rm -f `find . -type f -name '*~' -not -path "./.venv/*"`
rm -f `find . -type f -name '.*~' -not -path "./.venv/*"`
rm -f `find . -type f -name '*.cpython-*' -not -path "./.venv/*"`
rm -rf dist
rm -rf build
rm -rf target
Expand Down
8 changes: 7 additions & 1 deletion downsample_rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ license = "MIT"
[dependencies]
# TODO: perhaps use polars?
argminmax = { version = "0.6.1", features = ["half"] }
half = { version = "2.3.1", default-features = false , features=["num-traits"], optional = true}
half = { version = "2.3.1", default-features = false, features = [
"num-traits",
], optional = true }
num-traits = { version = "0.2.17", default-features = false }
once_cell = "1"
rayon = { version = "1.8.0", default-features = false }
Expand All @@ -35,3 +37,7 @@ harness = false
[[bench]]
name = "bench_minmaxlttb"
harness = false

[[bench]]
name = "bench_fpcs"
harness = false
92 changes: 92 additions & 0 deletions downsample_rs/benches/bench_fpcs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use dev_utils::{config, utils};
use downsample_rs::fpcs as fpcs_mod;

fn fpcs_f32_random_array_long(c: &mut Criterion) {
let n = config::ARRAY_LENGTH_LONG;
let y = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
let x = (0..n).map(|i| i as i32).collect::<Vec<i32>>();

// Non parallel
// --- without x
c.bench_function("fpcs_vanilla_f32", |b| {
b.iter(|| fpcs_mod::vanilla_fpcs_without_x(black_box(y.as_slice()), black_box(2_000)))
});
c.bench_function("fpcs_mm_f32", |b| {
b.iter(|| fpcs_mod::fpcs_without_x(black_box(y.as_slice()), black_box(2_000)))
});
// --- with x
c.bench_function("fpcs_mm_f32_x", |b| {
b.iter(|| {
fpcs_mod::fpcs_with_x(
black_box(x.as_slice()),
black_box(y.as_slice()),
black_box(2_000),
)
})
});

// Parallel
// --- without x
c.bench_function("fpcs_mm_f32_par", |b| {
b.iter(|| fpcs_mod::fpcs_without_x_parallel(black_box(y.as_slice()), black_box(2_000)))
});
// --- with x
c.bench_function("fpcs_mm_f32_x_par", |b| {
b.iter(|| {
fpcs_mod::fpcs_with_x_parallel(
black_box(x.as_slice()),
black_box(y.as_slice()),
black_box(2_000),
)
})
});
}

fn fpcs_f32_random_array_50m(c: &mut Criterion) {
let n = 50_000_000;
let y = utils::get_random_array::<f32>(n, f32::MIN, f32::MAX);
let x = (0..n).map(|i| i as i32).collect::<Vec<i32>>();

// Non parallel
// --- without x
c.bench_function("fpcs_vanilla_50M_f32", |b| {
b.iter(|| fpcs_mod::vanilla_fpcs_without_x(black_box(y.as_slice()), black_box(2_000)))
});
c.bench_function("fpcs_mm_50M_f32", |b| {
b.iter(|| fpcs_mod::fpcs_without_x(black_box(y.as_slice()), black_box(2_000)))
});
// --- with x
c.bench_function("fpcs_mm_50M_f32_x", |b| {
b.iter(|| {
fpcs_mod::fpcs_with_x(
black_box(x.as_slice()),
black_box(y.as_slice()),
black_box(2_000),
)
})
});
// Parallel
// --- without x
c.bench_function("fpcs_mm_50M_f32_par", |b| {
b.iter(|| fpcs_mod::fpcs_without_x_parallel(black_box(y.as_slice()), black_box(2_000)))
});
// --- with x
c.bench_function("fpcs_mm_50M_f32_x_par", |b| {
b.iter(|| {
fpcs_mod::fpcs_with_x_parallel(
black_box(x.as_slice()),
black_box(y.as_slice()),
black_box(2_000),
)
})
});
}

criterion_group!(
benches,
//
fpcs_f32_random_array_long,
fpcs_f32_random_array_50m,
);
criterion_main!(benches);
Loading
Loading