1+ use  std:: borrow:: Cow ; 
12use  std:: fs; 
23use  std:: io:: { BufWriter ,  Write } ; 
34use  std:: mem; 
@@ -20,12 +21,12 @@ pub enum ProfileCategory {
2021    Other , 
2122} 
2223
23- #[ derive( Clone ,  Copy ,   Debug ,  Eq ,  PartialEq ) ]  
24+ #[ derive( Clone ,  Debug ,  Eq ,  PartialEq ) ]  
2425pub  enum  ProfilerEvent  { 
2526    QueryStart  {  query_name :  & ' static  str ,  category :  ProfileCategory ,  time :  u64  } , 
2627    QueryEnd  {  query_name :  & ' static  str ,  category :  ProfileCategory ,  time :  u64  } , 
27-     GenericActivityStart  {  category :  ProfileCategory ,  time :  u64  } , 
28-     GenericActivityEnd  {  category :  ProfileCategory ,  time :  u64  } , 
28+     GenericActivityStart  {  category :  ProfileCategory ,  label :   Cow < ' static ,   str > ,   time :  u64  } , 
29+     GenericActivityEnd  {  category :  ProfileCategory ,  label :   Cow < ' static ,   str > ,   time :  u64  } , 
2930    IncrementalLoadResultStart  {  query_name :  & ' static  str ,  time :  u64  } , 
3031    IncrementalLoadResultEnd  {  query_name :  & ' static  str ,  time :  u64  } , 
3132    QueryCacheHit  {  query_name :  & ' static  str ,  category :  ProfileCategory ,  time :  u64  } , 
@@ -75,17 +76,27 @@ impl SelfProfiler {
7576    } 
7677
7778    #[ inline]  
78-     pub  fn  start_activity ( & mut  self ,  category :  ProfileCategory )  { 
79+     pub  fn  start_activity ( 
80+         & mut  self , 
81+         category :  ProfileCategory , 
82+         label :  impl  Into < Cow < ' static ,  str > > , 
83+     )  { 
7984        self . record ( ProfilerEvent :: GenericActivityStart  { 
8085            category, 
86+             label :  label. into ( ) , 
8187            time :  self . get_time_from_start ( ) , 
8288        } ) 
8389    } 
8490
8591    #[ inline]  
86-     pub  fn  end_activity ( & mut  self ,  category :  ProfileCategory )  { 
92+     pub  fn  end_activity ( 
93+         & mut  self , 
94+         category :  ProfileCategory , 
95+         label :  impl  Into < Cow < ' static ,  str > > , 
96+     )  { 
8797        self . record ( ProfilerEvent :: GenericActivityEnd  { 
8898            category, 
99+             label :  label. into ( ) , 
89100            time :  self . get_time_from_start ( ) , 
90101        } ) 
91102    } 
@@ -273,11 +284,12 @@ impl SelfProfiler {
273284                            nanos, 
274285                            thread_id, 
275286                        ) . unwrap ( ) , 
276-                     GenericActivityStart  {  category,  time :  _ }  =>
287+                     GenericActivityStart  {  category,  label ,   time :  _ }  =>
277288                        write ! ( file, 
278289                            "{{ 
279290                                \" GenericActivityStart\" : {{\  
280291                                     \" category\" : \" {:?}\" ,\ 
292+                                      \" label\" : \" {}\" ,\ 
281293                                     \" time\" : {{\ 
282294                                         \" secs\" : {},\ 
283295                                         \" nanos\" : {}\ 
@@ -286,15 +298,17 @@ impl SelfProfiler {
286298                                 }}\ 
287299                             }}", 
288300                            category, 
301+                             label, 
289302                            secs, 
290303                            nanos, 
291304                            thread_id, 
292305                        ) . unwrap ( ) , 
293-                     GenericActivityEnd  {  category,  time :  _ }  =>
306+                     GenericActivityEnd  {  category,  label ,   time :  _ }  =>
294307                        write ! ( file, 
295308                            "{{\  
296309                                 \" GenericActivityEnd\" : {{\ 
297310                                     \" category\" : \" {:?}\" ,\ 
311+                                      \" label\" : \" {}\" ,\ 
298312                                     \" time\" : {{\ 
299313                                         \" secs\" : {},\ 
300314                                         \" nanos\" : {}\ 
@@ -303,6 +317,7 @@ impl SelfProfiler {
303317                                 }}\ 
304318                             }}", 
305319                            category, 
320+                             label, 
306321                            secs, 
307322                            nanos, 
308323                            thread_id, 
@@ -418,7 +433,7 @@ impl SelfProfiler {
418433                            secs, 
419434                            nanos, 
420435                            thread_id, 
421-                         ) . unwrap ( ) 
436+                         ) . unwrap ( ) , 
422437                } 
423438            } 
424439        } 
0 commit comments