Skip to content

Commit 3cbc0f2

Browse files
committed
refactor: tune divan benchmarks
1 parent 533ded3 commit 3cbc0f2

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

benches/base.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@ static DB: LazyLock<NamedTempFile> = LazyLock::new(|| {
2525
db
2626
});
2727

28-
#[divan::bench(args = [1, 10, 100, 1000])]
28+
#[divan::bench(args = [1, 10, 100, 10_000, 100_000, 1_000_000])]
2929
fn store(n: usize) {
3030
let db = get_temp();
3131

3232
let bytes = OsString::from_str("a".repeat(n).as_ref()).unwrap();
33-
for _ in 0..n {
34-
let args = StoreArgs {
35-
bytes: Some(bytes.clone()),
36-
..Default::default()
37-
};
38-
store::execute(db.path(), args).expect("failed to store");
33+
let args = StoreArgs {
34+
bytes: Some(bytes),
35+
..Default::default()
36+
};
37+
38+
for _ in 0..100 {
39+
store::execute(db.path(), args.clone()).expect("failed to store");
3940
}
4041
}
4142

@@ -48,20 +49,22 @@ fn list(n: usize) {
4849
..Default::default()
4950
};
5051

51-
list::execute_without_output(path_db, args).expect("failed to list");
52+
for _ in 0..10 {
53+
list::execute_without_output(path_db, args.clone()).expect("failed to list");
54+
}
5255
}
5356

5457
#[divan::bench(args = [-100000, -1, 0, 1, 100000])]
5558
fn get(n: isize) {
5659
let path_db = DB.path();
5760

58-
for _ in 0..100 {
59-
let args = GetDelArgs {
60-
input: String::new(),
61-
index: Some(n),
62-
};
61+
let args = GetDelArgs {
62+
input: String::new(),
63+
index: Some(n),
64+
};
6365

64-
get::execute_without_output(path_db, args).expect("failed to get");
66+
for _ in 0..100 {
67+
get::execute_without_output(path_db, args.clone()).expect("failed to get");
6568
}
6669
}
6770

0 commit comments

Comments
 (0)