Skip to content

Commit

Permalink
Merge pull request #195 from 56quarters/perf-improvements
Browse files Browse the repository at this point in the history
Preallocate vec for multiple keys
  • Loading branch information
56quarters authored Dec 31, 2024
2 parents a618074 + 836619a commit 7816823
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions mtop-client/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,11 @@ impl Key {
I: IntoIterator<Item = T>,
T: Into<String>,
{
let mut out = Vec::new();
for val in vals {
let iter = vals.into_iter();
let (sz, _) = iter.size_hint();
let mut out = Vec::with_capacity(sz);

for val in iter {
out.push(Self::one(val)?);
}

Expand Down
3 changes: 2 additions & 1 deletion mtop/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ impl Bencher {
let mut stats = Summary { worker, ..Default::default() };

while !stop.load(Ordering::Acquire) && start.elapsed() < time {
let set_start = interval.tick().await;
let _ = interval.tick().await;
let set_start = Instant::now();

for kv in fixture.kvs.iter() {
// Write a small percentage of fixture data because cache workloads skew read heavy.
Expand Down

0 comments on commit 7816823

Please sign in to comment.