Skip to content

Commit

Permalink
Add unit test of re_smart_channel is_connected (#2119)
Browse files Browse the repository at this point in the history
Follow-up to #2106
  • Loading branch information
emilk authored May 16, 2023
1 parent 4f60fd7 commit c2e5fa9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions crates/re_smart_channel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,26 @@ fn test_smart_channel() {
assert_eq!(rx.len(), 0);
assert!(tx.latency_ns() > 1_000_000);
}

#[test]
fn test_smart_channel_connected() {
let (tx1, rx) = smart_channel(Source::Sdk); // whatever source
assert_eq!(rx.try_recv(), Err(TryRecvError::Empty));
assert!(rx.is_connected());

let tx2 = tx1.clone();
assert_eq!(rx.try_recv(), Err(TryRecvError::Empty));
assert!(rx.is_connected());

tx2.send(42).unwrap();
assert_eq!(rx.try_recv(), Ok(42));
assert!(rx.is_connected());

drop(tx1);
assert_eq!(rx.try_recv(), Err(TryRecvError::Empty));
assert!(rx.is_connected());

drop(tx2);
assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected));
assert!(!rx.is_connected());
}

1 comment on commit c2e5fa9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Rust Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.25.

Benchmark suite Current: c2e5fa9 Previous: 4f60fd7 Ratio
datastore/num_rows=1000/num_instances=1000/packed=false/insert/default 3418549 ns/iter (± 60885) 2436107 ns/iter (± 64553) 1.40
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at/default 369 ns/iter (± 4) 283 ns/iter (± 1) 1.30
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at_missing/primary/default 268 ns/iter (± 6) 206 ns/iter (± 0) 1.30
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at_missing/secondaries/default 419 ns/iter (± 0) 327 ns/iter (± 4) 1.28
datastore/num_rows=1000/num_instances=1000/packed=false/range/default 3517614 ns/iter (± 37940) 2501615 ns/iter (± 9592) 1.41
datastore/num_rows=1000/num_instances=1000/gc/default 2464797 ns/iter (± 4271) 1613661 ns/iter (± 11125) 1.53
mono_points_arrow/generate_message_bundles 29532367 ns/iter (± 555137) 21622271 ns/iter (± 589912) 1.37
mono_points_arrow/decode_message_bundles 63632516 ns/iter (± 569300) 50640804 ns/iter (± 520740) 1.26
mono_points_arrow_batched/generate_message_bundles 24728940 ns/iter (± 672167) 15611813 ns/iter (± 109389) 1.58
mono_points_arrow_batched/generate_messages 5163688 ns/iter (± 259484) 3034057 ns/iter (± 11994) 1.70
mono_points_arrow_batched/encode_total 29795132 ns/iter (± 1400950) 20022859 ns/iter (± 110035) 1.49
mono_points_arrow_batched/decode_log_msg 742550 ns/iter (± 3408) 463625 ns/iter (± 2428) 1.60
mono_points_arrow_batched/decode_message_bundles 7730310 ns/iter (± 189811) 6167585 ns/iter (± 22556) 1.25
mono_points_arrow_batched/decode_total 8669825 ns/iter (± 266594) 6684379 ns/iter (± 47392) 1.30
arrow_mono_points/insert 2287762678 ns/iter (± 3254963) 1519135598 ns/iter (± 3733141) 1.51
arrow_mono_points/query 1255184 ns/iter (± 8534) 874172 ns/iter (± 7762) 1.44
arrow_batch_points/query 17049 ns/iter (± 27) 12593 ns/iter (± 110) 1.35
arrow_batch_vecs/query 387434 ns/iter (± 288) 296399 ns/iter (± 7717) 1.31

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.