Skip to content

Commit db6a337

Browse files
committed
chore: bench
1 parent 040f64f commit db6a337

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

rust/cubestore/cubestore/benches/cachestore_queue.rs

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ async fn do_insert(
4040
total: usize,
4141
size_kb: usize,
4242
queue_path: &str,
43+
insert_id_padding: usize,
4344
) {
4445
for i in 0..total {
4546
let fut = cachestore.queue_add(QueueAddPayload {
46-
path: generate_queue_path(queue_path, i),
47+
path: generate_queue_path(queue_path, i + insert_id_padding),
4748
value: "a".repeat(size_kb * 1024), // size in bytes
4849
priority: 0,
4950
orphaned: None,
@@ -63,8 +64,20 @@ fn do_insert_bench(c: &mut Criterion, runtime: &Runtime, total: usize, size_kb:
6364
BenchmarkId::new(format!("queue_add queues:1, size:{} kb", size_kb), total),
6465
&(total, size_kb),
6566
|b, (total, size_kb)| {
66-
b.to_async(runtime)
67-
.iter(|| do_insert(&cachestore, *total, *size_kb, "STANDALONE#queue"));
67+
let mut insert_id_padding = 0;
68+
69+
b.to_async(runtime).iter(|| {
70+
let prev_value = insert_id_padding.clone();
71+
insert_id_padding += total;
72+
73+
do_insert(
74+
&cachestore,
75+
*total,
76+
*size_kb,
77+
&"STANDALONE#queue",
78+
prev_value,
79+
)
80+
});
6881
},
6982
);
7083
}
@@ -103,11 +116,11 @@ fn do_list_bench(
103116
))
104117
.unwrap();
105118

106-
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue").await;
107-
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue").await;
108-
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue").await;
109-
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue").await;
110-
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue").await;
119+
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue", 0).await;
120+
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue", 0).await;
121+
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue", 0).await;
122+
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue", 0).await;
123+
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue", 0).await;
111124

112125
cachestore
113126
});
@@ -150,11 +163,11 @@ fn do_get_bench(
150163
let cachestore = runtime.block_on(async {
151164
let cachestore = prepare_cachestore(&format!("cachestore_queue_get_{}", size_kb)).unwrap();
152165

153-
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue").await;
154-
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue").await;
155-
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue").await;
156-
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue").await;
157-
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue").await;
166+
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue", 0).await;
167+
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue", 0).await;
168+
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue", 0).await;
169+
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue", 0).await;
170+
do_insert(&cachestore, per_queue, size_kb, "STANDALONE#queue", 0).await;
158171

159172
cachestore
160173
});
@@ -177,9 +190,9 @@ fn do_get_bench(
177190
fn do_benches(c: &mut Criterion) {
178191
let runtime = Builder::new_multi_thread().enable_all().build().unwrap();
179192

180-
do_insert_bench(c, &runtime, 1_000, 64);
181-
do_insert_bench(c, &runtime, 1_000, 256);
182-
do_insert_bench(c, &runtime, 1_000, 512);
193+
do_insert_bench(c, &runtime, 512, 64);
194+
do_insert_bench(c, &runtime, 512, 256);
195+
do_insert_bench(c, &runtime, 512, 512);
183196

184197
do_list_bench(c, &runtime, Some(QueueItemStatus::Pending), 1_000, 128, 128);
185198
do_list_bench(c, &runtime, Some(QueueItemStatus::Active), 1_000, 128, 128);

0 commit comments

Comments
 (0)