@@ -23,6 +23,11 @@ pub fn benchmark(c: &mut Criterion) {
2323 input. publish ( ) ;
2424 } )
2525 } ) ;
26+ uncontended. bench_function ( "write input & publish" , |b| {
27+ b. iter ( || {
28+ * input. input_buffer_publisher ( ) = black_box ( 0 ) ;
29+ } )
30+ } ) ;
2631 uncontended. bench_function ( "send" , |b| b. iter ( || input. write ( black_box ( 0 ) ) ) ) ;
2732 uncontended. bench_function ( "publish + dirty update" , |b| {
2833 b. iter ( || {
@@ -36,6 +41,13 @@ pub fn benchmark(c: &mut Criterion) {
3641 * output. read ( )
3742 } )
3843 } ) ;
44+
45+ uncontended. bench_function ( "guarded transmit" , |b| {
46+ b. iter ( || {
47+ * input. input_buffer_publisher ( ) = black_box ( 0 ) ;
48+ * output. read ( )
49+ } )
50+ } ) ;
3951 }
4052
4153 {
@@ -53,6 +65,10 @@ pub fn benchmark(c: &mut Criterion) {
5365 input. publish ( ) ;
5466 } )
5567 } ) ;
68+ read_contended. bench_function ( "guarded write+send" , |b| {
69+ b. iter ( || * input. input_buffer_publisher ( ) = black_box ( 0 ) )
70+ } ) ;
71+
5672 read_contended. bench_function ( "send" , |b| b. iter ( || input. write ( black_box ( 0 ) ) ) ) ;
5773 } ,
5874 ) ;
@@ -74,67 +90,6 @@ pub fn benchmark(c: &mut Criterion) {
7490 } ,
7591 ) ;
7692 }
77-
78- {
79- let mut uncontended = c. benchmark_group ( "uncontended guarded" ) ;
80- uncontended. bench_function ( "read output" , |b| b. iter ( || * output. output_buffer ( ) ) ) ;
81- uncontended. bench_function ( "clean update" , |b| {
82- b. iter ( || {
83- output. update ( ) ;
84- } )
85- } ) ;
86- uncontended. bench_function ( "clean receive" , |b| b. iter ( || * output. read ( ) ) ) ;
87- uncontended. bench_function ( "write input" , |b| {
88- b. iter ( || {
89- * input. input_buffer_publisher ( ) = black_box ( 0 ) ;
90- } )
91- } ) ;
92- uncontended. bench_function ( "send" , |b| {
93- b. iter ( || * input. input_buffer_publisher ( ) = black_box ( 0 ) )
94- } ) ;
95- uncontended. bench_function ( "transmit" , |b| {
96- b. iter ( || {
97- * input. input_buffer_publisher ( ) = black_box ( 0 ) ;
98- * output. read ( )
99- } )
100- } ) ;
101- }
102-
103- {
104- let ( mut input, mut output) = TripleBuffer :: < u8 > :: default ( ) . split ( ) ;
105- let mut read_contended = c. benchmark_group ( "read contention guarded" ) ;
106- testbench:: run_under_contention (
107- move || black_box ( * output. read ( ) ) ,
108- || {
109- read_contended. bench_function ( "write input" , |b| {
110- b. iter ( || {
111- * input. input_buffer_publisher ( ) = black_box ( 0 ) ;
112- } )
113- } ) ;
114- read_contended. bench_function ( "send" , |b| {
115- b. iter ( || * input. input_buffer_publisher ( ) = black_box ( 0 ) )
116- } ) ;
117- } ,
118- ) ;
119- }
120-
121- {
122- let ( mut input, mut output) = TripleBuffer :: < u8 > :: default ( ) . split ( ) ;
123- let mut write_contended = c. benchmark_group ( "guarded write contention" ) ;
124- testbench:: run_under_contention (
125- || * input. input_buffer_publisher ( ) = black_box ( 0 ) ,
126- || {
127- write_contended
128- . bench_function ( "read output" , |b| b. iter ( || * output. output_buffer ( ) ) ) ;
129- write_contended. bench_function ( "update" , |b| {
130- b. iter ( || {
131- output. update ( ) ;
132- } )
133- } ) ;
134- write_contended. bench_function ( "receive" , |b| b. iter ( || * output. read ( ) ) ) ;
135- } ,
136- ) ;
137- }
13893}
13994
14095criterion_group ! ( benches, benchmark) ;
0 commit comments