1
1
use message_io:: network:: { self , Transport , NetworkController , NetworkProcessor , Endpoint } ;
2
2
use message_io:: util:: thread:: { NamespacedThread } ;
3
3
4
- use criterion:: { criterion_group, criterion_main, Criterion , BenchmarkId , Throughput } ;
4
+ use criterion:: { criterion_group, criterion_main, Criterion } ;
5
5
6
6
use std:: time:: { Duration } ;
7
7
use std:: sync:: {
@@ -49,44 +49,6 @@ fn latency_by(c: &mut Criterion, transport: Transport) {
49
49
} ) ;
50
50
}
51
51
52
- fn throughput_by ( c : & mut Criterion , transport : Transport ) {
53
- let sizes = [ 1 , 2 , 4 , 8 , 16 , 32 , 64 , 128 ]
54
- . iter ( )
55
- . map ( |i| i * 1024 )
56
- . filter ( |& size| size < transport. max_message_size ( ) ) ;
57
-
58
- for block_size in sizes {
59
- let mut group = c. benchmark_group ( format ! ( "throughput by {}" , transport) ) ;
60
- group. throughput ( Throughput :: Bytes ( block_size as u64 ) ) ;
61
- group. bench_with_input ( BenchmarkId :: from_parameter ( block_size) , & block_size, |b, & size| {
62
- let ( controller, mut processor, endpoint) = init_connection ( transport) ;
63
-
64
- let thread_running = Arc :: new ( AtomicBool :: new ( true ) ) ;
65
- let running = thread_running. clone ( ) ;
66
- let ( tx, rx) = std:: sync:: mpsc:: channel ( ) ;
67
- let mut thread = NamespacedThread :: spawn ( "perf-sender" , move || {
68
- let message = ( 0 ..size) . map ( |_| 0xFF ) . collect :: < Vec < u8 > > ( ) ;
69
- tx. send ( ( ) ) . unwrap ( ) ; // receiving thread ready
70
- while running. load ( Ordering :: Relaxed ) {
71
- controller. send ( endpoint, & message) ;
72
- }
73
- } ) ;
74
- rx. recv ( ) . unwrap ( ) ;
75
-
76
- b. iter ( || {
77
- // FIX IT:
78
- // Because the sender do not stop sends, the receiver has always data.
79
- // This means that only one poll event is generated for all messages, and
80
- // process_poll_event will call the callback continuously without ends.
81
- processor. process_poll_event ( Some ( * TIMEOUT ) , |_| ( ) ) ;
82
- } ) ;
83
-
84
- thread_running. store ( true , Ordering :: Relaxed ) ;
85
- thread. join ( ) ;
86
- } ) ;
87
- }
88
- }
89
-
90
52
fn latency ( c : & mut Criterion ) {
91
53
#[ cfg( feature = "udp" ) ]
92
54
latency_by ( c, Transport :: Udp ) ;
@@ -98,18 +60,5 @@ fn latency(c: &mut Criterion) {
98
60
latency_by ( c, Transport :: Ws ) ;
99
61
}
100
62
101
- #[ allow( dead_code) ] //TODO: remove when the throughput test works fine
102
- fn throughput ( c : & mut Criterion ) {
103
- #[ cfg( feature = "udp" ) ]
104
- throughput_by ( c, Transport :: Udp ) ;
105
- // TODO: Fix this test: How to read inside of criterion iter() an stream protocol?
106
- // #[cfg(feature = "tcp")]
107
- // throughput_by(c, Transport::Tcp);
108
- #[ cfg( feature = "tcp" ) ]
109
- throughput_by ( c, Transport :: FramedTcp ) ;
110
- #[ cfg( feature = "websocket" ) ]
111
- throughput_by ( c, Transport :: Ws ) ;
112
- }
113
-
114
- criterion_group ! ( benches, latency /*throughput*/ , ) ;
63
+ criterion_group ! ( benches, latency) ;
115
64
criterion_main ! ( benches) ;
0 commit comments