This repository has no description
832 B
32 lines
1use std::time::Duration;
2
3use knot_index::Index;
4use knot_types::RepoDid;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub struct OpenLatency(Duration);
8
9impl OpenLatency {
10 pub fn micros(value: u64) -> Self {
11 Self(Duration::from_micros(value))
12 }
13 pub fn zero() -> Self {
14 Self(Duration::ZERO)
15 }
16 fn stall(self) {
17 if !self.0.is_zero() {
18 std::thread::sleep(self.0);
19 }
20 }
21}
22
23pub fn replay_boot(index: &Index, repos: &[RepoDid], per_open: OpenLatency) {
24 index.refresh_members().expect("fold members");
25 index.refresh_registry().expect("fold registry");
26 repos.iter().for_each(|repo| {
27 per_open.stall();
28 index
29 .refresh_collaborators(repo)
30 .expect("fabric-boot repo must fold, otherwise bench measures nothing");
31 });
32}