File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -18,4 +18,12 @@ exclude = ["/.*"]
18
18
parking = " 2.0.0"
19
19
20
20
[dev-dependencies ]
21
+ criterion = " 0.3.4"
21
22
waker-fn = " 1"
23
+
24
+ [[bench ]]
25
+ name = " bench"
26
+ harness = false
27
+
28
+ [lib ]
29
+ bench = false
Original file line number Diff line number Diff line change
1
+ use criterion:: { criterion_group, criterion_main, Criterion } ;
2
+ use event_listener:: Event ;
3
+
4
+ const COUNT : usize = 8000 ;
5
+
6
+ fn bench_events ( c : & mut Criterion ) {
7
+ c. bench_function ( "notify_and_wait" , |b| {
8
+ let ev = Event :: new ( ) ;
9
+ b. iter ( || {
10
+ let mut handles = Vec :: with_capacity ( COUNT ) ;
11
+
12
+ for _ in 0 ..COUNT {
13
+ handles. push ( ev. listen ( ) ) ;
14
+ }
15
+
16
+ ev. notify ( COUNT ) ;
17
+
18
+ for handle in handles {
19
+ handle. wait ( ) ;
20
+ }
21
+ } ) ;
22
+ } ) ;
23
+ }
24
+
25
+ criterion_group ! ( benches, bench_events) ;
26
+ criterion_main ! ( benches) ;
You can’t perform that action at this time.
0 commit comments