1
1
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
3
3
4
+ #[ cfg( feature = "test_utilities" ) ]
4
5
use criterion:: { criterion_group, criterion_main, Criterion } ;
5
6
7
+ #[ cfg( feature = "test_utilities" ) ]
6
8
use event_manager:: utilities:: subscribers:: {
7
9
CounterInnerMutSubscriber , CounterSubscriber , CounterSubscriberWithData ,
8
10
} ;
11
+ #[ cfg( feature = "test_utilities" ) ]
9
12
use event_manager:: { EventManager , EventSubscriber , MutEventSubscriber , SubscriberOps } ;
13
+ #[ cfg( feature = "test_utilities" ) ]
10
14
use std:: sync:: { Arc , Mutex } ;
11
15
12
16
// Test the performance of event manager when it manages a single subscriber type.
13
17
// The performance is assessed under stress, all added subscribers have active events.
18
+ #[ cfg( feature = "test_utilities" ) ]
14
19
fn run_basic_subscriber ( c : & mut Criterion ) {
15
20
let no_of_subscribers = 200 ;
16
21
@@ -31,6 +36,7 @@ fn run_basic_subscriber(c: &mut Criterion) {
31
36
32
37
// Test the performance of event manager when the subscribers are wrapped in an Arc<Mutex>.
33
38
// The performance is assessed under stress, all added subscribers have active events.
39
+ #[ cfg( feature = "test_utilities" ) ]
34
40
fn run_arc_mutex_subscriber ( c : & mut Criterion ) {
35
41
let no_of_subscribers = 200 ;
36
42
@@ -52,6 +58,7 @@ fn run_arc_mutex_subscriber(c: &mut Criterion) {
52
58
// Test the performance of event manager when the subscribers are wrapped in an Arc, and they
53
59
// leverage inner mutability to update their internal state.
54
60
// The performance is assessed under stress, all added subscribers have active events.
61
+ #[ cfg( feature = "test_utilities" ) ]
55
62
fn run_subscriber_with_inner_mut ( c : & mut Criterion ) {
56
63
let no_of_subscribers = 200 ;
57
64
@@ -75,6 +82,7 @@ fn run_subscriber_with_inner_mut(c: &mut Criterion) {
75
82
// (using CounterSubscriberWithData).
76
83
// The performance is assessed under stress, all added subscribers have active events, and the
77
84
// CounterSubscriberWithData subscribers have multiple active events.
85
+ #[ cfg( feature = "test_utilities" ) ]
78
86
fn run_multiple_subscriber_types ( c : & mut Criterion ) {
79
87
let no_of_subscribers = 100 ;
80
88
@@ -102,6 +110,7 @@ fn run_multiple_subscriber_types(c: &mut Criterion) {
102
110
103
111
// Test the performance of event manager when it manages a single subscriber type.
104
112
// Just a few of the events are active in this test scenario.
113
+ #[ cfg( feature = "test_utilities" ) ]
105
114
fn run_with_few_active_events ( c : & mut Criterion ) {
106
115
let no_of_subscribers = 200 ;
107
116
@@ -124,6 +133,7 @@ fn run_with_few_active_events(c: &mut Criterion) {
124
133
} ) ;
125
134
}
126
135
136
+ #[ cfg( feature = "test_utilities" ) ]
127
137
criterion_group ! {
128
138
name = benches;
129
139
config = Criterion :: default ( )
@@ -133,6 +143,10 @@ criterion_group! {
133
143
run_multiple_subscriber_types, run_with_few_active_events
134
144
}
135
145
146
+ #[ cfg( feature = "test_utilities" ) ]
136
147
criterion_main ! {
137
148
benches
138
149
}
150
+
151
+ #[ cfg( not( feature = "test_utilities" ) ) ]
152
+ fn main ( ) { }
0 commit comments