2
2
use criterion:: { criterion_group, criterion_main, Bencher , Criterion } ;
3
3
use futures:: StreamExt ;
4
4
use log:: * ;
5
- use pcap_async:: { Config , Handle , PacketStream , BridgeStream } ;
5
+ use pcap_async:: { BridgeStream , Config , Handle , PacketStream } ;
6
6
use std:: path:: PathBuf ;
7
7
8
8
fn bench_stream_from_large_file ( b : & mut Bencher ) {
@@ -15,7 +15,7 @@ fn bench_stream_from_large_file(b: &mut Bencher) {
15
15
info ! ( "Benchmarking against {:?}" , pcap_path. clone( ) ) ;
16
16
17
17
b. iter ( || {
18
- let rt = tokio:: runtime:: Runtime :: new ( ) . expect ( "Failed to create runtime" ) ;
18
+ let mut rt = tokio:: runtime:: Runtime :: new ( ) . expect ( "Failed to create runtime" ) ;
19
19
20
20
let clone_path = pcap_path. clone ( ) ;
21
21
@@ -63,7 +63,7 @@ fn bench_stream_next_from_large_file_bridge(b: &mut Bencher) {
63
63
info ! ( "Benchmarking against {:?}" , pcap_path. clone( ) ) ;
64
64
65
65
b. iter ( || {
66
- let rt = tokio:: runtime:: Runtime :: new ( ) . expect ( "Failed to create runtime" ) ;
66
+ let mut rt = tokio:: runtime:: Runtime :: new ( ) . expect ( "Failed to create runtime" ) ;
67
67
68
68
let clone_path = pcap_path. clone ( ) ;
69
69
@@ -76,8 +76,9 @@ fn bench_stream_next_from_large_file_bridge(b: &mut Bencher) {
76
76
let mut cfg = Config :: default ( ) ;
77
77
cfg. with_max_packets_read ( 5000 ) ;
78
78
79
- let packet_provider = BridgeStream :: new ( Config :: default ( ) , vec ! [ handle1. clone( ) , handle2. clone( ) ] )
80
- . expect ( "Failed to build" ) ;
79
+ let packet_provider =
80
+ BridgeStream :: new ( Config :: default ( ) , vec ! [ handle1. clone( ) , handle2. clone( ) ] )
81
+ . expect ( "Failed to build" ) ;
81
82
let fut_packets = async move {
82
83
let mut packet_provider = packet_provider. boxed ( ) ;
83
84
let mut packets = vec ! [ ] ;
@@ -106,7 +107,7 @@ fn bench_stream_next_from_large_file(b: &mut Bencher) {
106
107
info ! ( "Benchmarking against {:?}" , pcap_path. clone( ) ) ;
107
108
108
109
b. iter ( || {
109
- let rt = tokio:: runtime:: Runtime :: new ( ) . expect ( "Failed to create runtime" ) ;
110
+ let mut rt = tokio:: runtime:: Runtime :: new ( ) . expect ( "Failed to create runtime" ) ;
110
111
111
112
let clone_path = pcap_path. clone ( ) ;
112
113
@@ -136,7 +137,8 @@ fn bench_stream_next_from_large_file(b: &mut Bencher) {
136
137
}
137
138
138
139
fn bench_stream_next_bridge ( c : & mut Criterion ) {
139
- let benchmark = criterion:: Benchmark :: new ( "4sics-bridge" , bench_stream_next_from_large_file_bridge) ;
140
+ let benchmark =
141
+ criterion:: Benchmark :: new ( "4sics-bridge" , bench_stream_next_from_large_file_bridge) ;
140
142
141
143
c. bench (
142
144
"stream_next" ,
@@ -159,7 +161,12 @@ fn bench_stream_next(c: &mut Criterion) {
159
161
) ;
160
162
}
161
163
162
- criterion_group ! ( benches, bench_stream, bench_stream_next, bench_stream_next_bridge) ;
164
+ criterion_group ! (
165
+ benches,
166
+ bench_stream,
167
+ bench_stream_next,
168
+ bench_stream_next_bridge
169
+ ) ;
163
170
164
171
// Benchmark: cargo bench --verbose
165
172
0 commit comments