|
|
|
@@ -20,20 +20,27 @@ fn main() -> eyre::Result<()> { |
|
|
|
match event { |
|
|
|
dora_node_api::Event::Input { |
|
|
|
id: _, |
|
|
|
metadata: _, |
|
|
|
metadata, |
|
|
|
data, |
|
|
|
} => { |
|
|
|
let data: &PrimitiveArray<UInt64Type> = data.as_primitive(); |
|
|
|
let time: u64 = data.values()[0]; |
|
|
|
let time_metadata = metadata.timestamp(); |
|
|
|
let duration_metadata = time_metadata.get_time().to_system_time().elapsed()?; |
|
|
|
println!("Latency duration: {:?}", duration_metadata); |
|
|
|
assert!( |
|
|
|
duration_metadata < Duration::from_millis(500), |
|
|
|
"Time difference should be less than 500ms" |
|
|
|
); |
|
|
|
let time = time as f64; |
|
|
|
let now = Utc::now(); |
|
|
|
|
|
|
|
let timestamp = now.timestamp_nanos_opt().unwrap() as f64; |
|
|
|
let duration = (timestamp - time) / 1_000_000_000.; |
|
|
|
println!("Time Difference: {:?}", duration); |
|
|
|
let duration = Duration::from_nanos((timestamp - time) as u64); |
|
|
|
println!("Latency duration: {:?}", duration); |
|
|
|
assert!( |
|
|
|
duration < 1., |
|
|
|
"Time difference should be less than 2 seconds as data is sent every seconds" |
|
|
|
duration < Duration::from_millis(500), |
|
|
|
"Time difference should be less than 500ms" |
|
|
|
); |
|
|
|
} |
|
|
|
_ => {} |
|
|
|
|