Skip to content

Commit

Permalink
Update downsampling tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Jan 24, 2024
1 parent d763f06 commit 7754b65
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions zenoh/tests/interceptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,24 @@ fn downsampling() {
.res()
.unwrap();

let ten_millis = std::time::Duration::from_millis(10);
let interval = std::time::Duration::from_millis(10);
let mut last_send_time = std::time::Instant::now();
for i in 0..100 {
let start_time = last_send_time;
println!("message {}", i);
publisher_r100.put(format!("message {}", i)).res().unwrap();
publisher_r50.put(format!("message {}", i)).res().unwrap();
std::thread::sleep(ten_millis);

let elapsed_time = start_time.elapsed();

let sleep_duration = if elapsed_time > interval {
std::time::Duration::from_millis(0)
} else {
interval - elapsed_time
};
std::thread::sleep(sleep_duration);

last_send_time = std::time::Instant::now();
}

// check result count of queries
Expand Down

0 comments on commit 7754b65

Please sign in to comment.