Skip to content

Commit

Permalink
Preparing bencher setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Benji377 committed Dec 22, 2023
1 parent c0a81c6 commit 1afa8b5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rust-analyzer.linkedProjects": [
".\\src-tauri\\Cargo.toml"
]
}
5 changes: 5 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ md5 = "0.7.0"
[dev-dependencies]
ctor = "0.2.6"
regex = "1.10.2"
criterion = "0.4"

[[bench]]
name = "raspirus_bench"
harness = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
19 changes: 19 additions & 0 deletions src-tauri/benches/raspirus_bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
// TODO: Add the function you want to benchmark here.
// Basically we could downlaod the database, prepare the database, and then
// benchmark a specific folder or file. We could also always ship the test folder with it or something
// Also, remember to test zip files too.
fn fibonacci(n: u64) -> u64 {
match n {
0 => 1,
1 => 1,
n => fibonacci(n-1) + fibonacci(n-2),
}
}

fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("fib 20", |b| b.iter(|| fibonacci(black_box(20))));
}

criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);
Binary file removed src-tauri/signatures.db
Binary file not shown.

0 comments on commit 1afa8b5

Please sign in to comment.