Skip to content

Commit

Permalink
*: enhance test in bench
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdroychan committed Aug 8, 2024
1 parent 59b02c3 commit ac9308b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 16 deletions.
30 changes: 29 additions & 1 deletion presets/benchmarks/example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ batch = 10
klen = 8
vlen = 16
kmin = 0
kmax = 1000
kmax = 10000

[[benchmark]]
set_perc = 100
Expand All @@ -24,3 +24,31 @@ timeout = 0.2
set_perc = 50
get_perc = 50
dist = "uniform"

[[benchmark]]
set_perc = 100
kmin = 10000
kmax = 20000
repeat = 1
dist = "shufflep"

[[benchmark]]
set_perc = 100
kmin = 20000
kmax = 30000
repeat = 1
dist = "incrementp"

[[benchmark]]
del_perc = 100
kmin = 5000
kmax = 15000
repeat = 1
dist = "shufflep"

[[benchmark]]
del_perc = 100
kmin = 15000
kmax = 25000
repeat = 1
dist = "incrementp"
2 changes: 1 addition & 1 deletion presets/benchmarks/example_scan.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ scan_n = 10
klen = 8
vlen = 16
kmin = 0
kmax = 1000
kmax = 10000

[[benchmark]]
set_perc = 100
Expand Down
50 changes: 36 additions & 14 deletions src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1311,11 +1311,33 @@ mod tests {
"/presets/benchmarks/example_scan.toml"
));

fn example(map_opt: &str) {
fn example(map_opt: &str, check: bool) {
let _ = env_logger::try_init();
let opt = map_opt.to_string() + "\n" + EXAMPLE_BENCH;
let (map, phases) = init(&opt);
map.bench(&phases);
if check {
if let BenchKVMap::Regular(m) = map {
let mut handle = m.handle();
// set 0-30000 and delete 5000-25000
for k in 0..5000u64 {
let key = k.to_be_bytes();
assert!(handle.get(&key).is_some());
}
for k in 5000..25000u64 {
let key = k.to_be_bytes();
assert!(handle.get(&key).is_none());
}
for k in 25000..30000u64 {
let key = k.to_be_bytes();
assert!(handle.get(&key).is_some());
}
for k in 30000..50000u64 {
let key = k.to_be_bytes();
assert!(handle.get(&key).is_none());
}
}
}
}

fn example_scan(map_opt: &str) {
Expand All @@ -1331,7 +1353,7 @@ mod tests {
env!("CARGO_MANIFEST_DIR"),
"/presets/stores/null.toml"
));
example(OPT);
example(OPT, false);
}

#[test]
Expand All @@ -1349,7 +1371,7 @@ mod tests {
env!("CARGO_MANIFEST_DIR"),
"/presets/stores/null_async.toml"
));
example(OPT);
example(OPT, false);
}

#[test]
Expand All @@ -1367,7 +1389,7 @@ mod tests {
env!("CARGO_MANIFEST_DIR"),
"/presets/stores/mutex_hashmap.toml"
));
example(OPT);
example(OPT, true);
}

#[test]
Expand All @@ -1376,7 +1398,7 @@ mod tests {
env!("CARGO_MANIFEST_DIR"),
"/presets/stores/rwlock_hashmap.toml"
));
example(OPT);
example(OPT, true);
}

#[test]
Expand All @@ -1386,7 +1408,7 @@ mod tests {
env!("CARGO_MANIFEST_DIR"),
"/presets/stores/dashmap.toml"
));
example(OPT);
example(OPT, true);
}

#[test]
Expand All @@ -1396,7 +1418,7 @@ mod tests {
env!("CARGO_MANIFEST_DIR"),
"/presets/stores/contrie.toml"
));
example(OPT);
example(OPT, true);
}

#[test]
Expand All @@ -1406,7 +1428,7 @@ mod tests {
env!("CARGO_MANIFEST_DIR"),
"/presets/stores/chashmap.toml"
));
example(OPT);
example(OPT, true);
}

#[test]
Expand All @@ -1416,7 +1438,7 @@ mod tests {
env!("CARGO_MANIFEST_DIR"),
"/presets/stores/scchashmap.toml"
));
example(OPT);
example(OPT, true);
}

#[test]
Expand All @@ -1426,7 +1448,7 @@ mod tests {
env!("CARGO_MANIFEST_DIR"),
"/presets/stores/flurry.toml"
));
example(OPT);
example(OPT, true);
}

#[test]
Expand All @@ -1436,7 +1458,7 @@ mod tests {
env!("CARGO_MANIFEST_DIR"),
"/presets/stores/papaya.toml"
));
example(OPT);
example(OPT, true);
}

#[test]
Expand All @@ -1445,7 +1467,7 @@ mod tests {
env!("CARGO_MANIFEST_DIR"),
"/presets/stores/mutex_btreemap.toml"
));
example(OPT);
example(OPT, true);
}

#[test]
Expand All @@ -1454,7 +1476,7 @@ mod tests {
env!("CARGO_MANIFEST_DIR"),
"/presets/stores/rwlock_btreemap.toml"
));
example(OPT);
example(OPT, true);
}

#[test]
Expand All @@ -1469,7 +1491,7 @@ mod tests {
"#,
tmp_dir.path().to_str().unwrap().to_string()
);
example(&opt);
example(&opt, true);
}

#[test]
Expand Down
1 change: 1 addition & 0 deletions src/workload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ mod tests {

#[test]
fn keygen_increment() {
// this also checks unaligned key
let mut rng = rand::thread_rng();
for len in [3, 8, 16] {
let mut kgen = KeyGenerator::new_increment(len, 0, 3);
Expand Down

0 comments on commit ac9308b

Please sign in to comment.