@@ -34,12 +34,6 @@ use crate::statistics::manager::ClientStatsManager;
3434
3535/// The monitor trait keeps track of all the client's monitor, and offers methods to display them.
3636pub trait Monitor {
37- /// Creation time
38- fn start_time ( & self ) -> Duration ;
39-
40- /// Set creation time
41- fn set_start_time ( & mut self , time : Duration ) ;
42-
4337 /// Show the monitor to the user
4438 fn display (
4539 & mut self ,
@@ -52,21 +46,9 @@ pub trait Monitor {
5246/// Monitor that print exactly nothing.
5347/// Not good for debugging, very good for speed.
5448#[ derive( Debug , Clone ) ]
55- pub struct NopMonitor {
56- start_time : Duration ,
57- }
49+ pub struct NopMonitor { }
5850
5951impl Monitor for NopMonitor {
60- /// Time this fuzzing run stated
61- fn start_time ( & self ) -> Duration {
62- self . start_time
63- }
64-
65- /// Time this fuzzing run stated
66- fn set_start_time ( & mut self , time : Duration ) {
67- self . start_time = time;
68- }
69-
7052 #[ inline]
7153 fn display (
7254 & mut self ,
@@ -81,9 +63,7 @@ impl NopMonitor {
8163 /// Create new [`NopMonitor`]
8264 #[ must_use]
8365 pub fn new ( ) -> Self {
84- Self {
85- start_time : current_time ( ) ,
86- }
66+ Self { }
8767 }
8868}
8969
@@ -95,19 +75,8 @@ impl Default for NopMonitor {
9575
9676/// Tracking monitor during fuzzing that just prints to `stdout`.
9777#[ cfg( feature = "std" ) ]
98- #[ derive( Debug , Clone ) ]
99- pub struct SimplePrintingMonitor {
100- start_time : Duration ,
101- }
102-
103- #[ cfg( feature = "std" ) ]
104- impl Default for SimplePrintingMonitor {
105- fn default ( ) -> Self {
106- Self {
107- start_time : current_time ( ) ,
108- }
109- }
110- }
78+ #[ derive( Debug , Clone , Default ) ]
79+ pub struct SimplePrintingMonitor { }
11180
11281#[ cfg( feature = "std" ) ]
11382impl SimplePrintingMonitor {
@@ -120,16 +89,6 @@ impl SimplePrintingMonitor {
12089
12190#[ cfg( feature = "std" ) ]
12291impl Monitor for SimplePrintingMonitor {
123- /// Time this fuzzing run stated
124- fn start_time ( & self ) -> Duration {
125- self . start_time
126- }
127-
128- /// Time this fuzzing run stated
129- fn set_start_time ( & mut self , time : Duration ) {
130- self . start_time = time;
131- }
132-
13392 fn display (
13493 & mut self ,
13594 client_stats_manager : & mut ClientStatsManager ,
@@ -146,7 +105,7 @@ impl Monitor for SimplePrintingMonitor {
146105 "[{} #{}] run time: {}, clients: {}, corpus: {}, objectives: {}, executions: {}, exec/sec: {}, {}" ,
147106 event_msg,
148107 sender_id. 0 ,
149- format_duration_hms( & ( current_time( ) - self . start_time) ) ,
108+ format_duration_hms( & ( current_time( ) - client_stats_manager . start_time( ) ) ) ,
150109 client_stats_manager. client_stats_count( ) ,
151110 client_stats_manager. corpus_size( ) ,
152111 client_stats_manager. objective_size( ) ,
@@ -177,7 +136,6 @@ where
177136 F : FnMut ( & str ) ,
178137{
179138 print_fn : F ,
180- start_time : Duration ,
181139 print_user_monitor : bool ,
182140}
183141
@@ -186,26 +144,14 @@ where
186144 F : FnMut ( & str ) ,
187145{
188146 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
189- f. debug_struct ( "SimpleMonitor" )
190- . field ( "start_time" , & self . start_time )
191- . finish_non_exhaustive ( )
147+ f. debug_struct ( "SimpleMonitor" ) . finish_non_exhaustive ( )
192148 }
193149}
194150
195151impl < F > Monitor for SimpleMonitor < F >
196152where
197153 F : FnMut ( & str ) ,
198154{
199- /// Time this fuzzing run stated
200- fn start_time ( & self ) -> Duration {
201- self . start_time
202- }
203-
204- /// Set creation time
205- fn set_start_time ( & mut self , time : Duration ) {
206- self . start_time = time;
207- }
208-
209155 fn display (
210156 & mut self ,
211157 client_stats_manager : & mut ClientStatsManager ,
@@ -216,7 +162,7 @@ where
216162 "[{} #{}] run time: {}, clients: {}, corpus: {}, objectives: {}, executions: {}, exec/sec: {}" ,
217163 event_msg,
218164 sender_id. 0 ,
219- format_duration_hms( & ( current_time( ) - self . start_time) ) ,
165+ format_duration_hms( & ( current_time( ) - client_stats_manager . start_time( ) ) ) ,
220166 client_stats_manager. client_stats_count( ) ,
221167 client_stats_manager. corpus_size( ) ,
222168 client_stats_manager. objective_size( ) ,
@@ -259,25 +205,23 @@ where
259205 pub fn new ( print_fn : F ) -> Self {
260206 Self {
261207 print_fn,
262- start_time : current_time ( ) ,
263208 print_user_monitor : false ,
264209 }
265210 }
266211
267212 /// Creates the monitor with a given `start_time`.
268- pub fn with_time ( print_fn : F , start_time : Duration ) -> Self {
269- Self {
270- print_fn ,
271- start_time ,
272- print_user_monitor : false ,
273- }
213+ # [ deprecated (
214+ since = "0.16.0" ,
215+ note = "Please use new to create. start_time is useless here."
216+ ) ]
217+ pub fn with_time ( print_fn : F , _start_time : Duration ) -> Self {
218+ Self :: new ( print_fn )
274219 }
275220
276221 /// Creates the monitor that also prints the user monitor
277222 pub fn with_user_monitor ( print_fn : F ) -> Self {
278223 Self {
279224 print_fn,
280- start_time : current_time ( ) ,
281225 print_user_monitor : true ,
282226 }
283227 }
@@ -320,34 +264,16 @@ macro_rules! mark_feedback_time {
320264pub struct CombinedMonitor < A , B > {
321265 first : A ,
322266 second : B ,
323- start_time : Duration ,
324267}
325268
326269impl < A : Monitor , B : Monitor > CombinedMonitor < A , B > {
327270 /// Create a new combined monitor
328- pub fn new ( mut first : A , mut second : B ) -> Self {
329- let start_time = current_time ( ) ;
330- first. set_start_time ( start_time) ;
331- second. set_start_time ( start_time) ;
332- Self {
333- first,
334- second,
335- start_time,
336- }
271+ pub fn new ( first : A , second : B ) -> Self {
272+ Self { first, second }
337273 }
338274}
339275
340276impl < A : Monitor , B : Monitor > Monitor for CombinedMonitor < A , B > {
341- fn start_time ( & self ) -> Duration {
342- self . start_time
343- }
344-
345- fn set_start_time ( & mut self , time : Duration ) {
346- self . start_time = time;
347- self . first . set_start_time ( time) ;
348- self . second . set_start_time ( time) ;
349- }
350-
351277 fn display (
352278 & mut self ,
353279 client_stats_manager : & mut ClientStatsManager ,
0 commit comments