File tree Expand file tree Collapse file tree 5 files changed +54
-0
lines changed
Expand file tree Collapse file tree 5 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,14 @@ impl MarkerTable {
106106 self
107107 }
108108
109+ pub fn start_times ( & self ) -> impl Iterator < Item = Timestamp > + use < ' _ > {
110+ self . marker_starts . iter ( ) . copied ( ) . flatten ( )
111+ }
112+
113+ pub fn end_times ( & self ) -> impl Iterator < Item = Timestamp > + use < ' _ > {
114+ self . marker_ends . iter ( ) . copied ( ) . flatten ( )
115+ }
116+
109117 pub fn as_serializable < ' a > (
110118 & ' a self ,
111119 schemas : & ' a [ InternalMarkerSchema ] ,
Original file line number Diff line number Diff line change @@ -1425,6 +1425,22 @@ impl Profile {
14251425 }
14261426 }
14271427
1428+ fn compute_profiling_time_range ( & self ) -> Option < ( Timestamp , Timestamp ) > {
1429+ self . threads
1430+ . iter ( )
1431+ . flat_map ( |thread| {
1432+ thread
1433+ . sample_timestamps ( )
1434+ . chain ( thread. marker_start_times ( ) )
1435+ . chain ( thread. marker_end_times ( ) )
1436+ } )
1437+ . fold ( None , |acc, timestamp| {
1438+ acc. map_or ( Some ( ( timestamp, timestamp) ) , |( min, max) | {
1439+ Some ( ( min. min ( timestamp) , max. max ( timestamp) ) )
1440+ } )
1441+ } )
1442+ }
1443+
14281444 fn contains_js_frame ( & self ) -> bool {
14291445 self . threads . iter ( ) . any ( |t| t. contains_js_frame ( ) )
14301446 }
@@ -1497,6 +1513,12 @@ impl Serialize for SerializableProfileMeta<'_> {
14971513 }
14981514 None => { }
14991515 }
1516+
1517+ if let Some ( ( start, end) ) = self . 0 . compute_profiling_time_range ( ) {
1518+ map. serialize_entry ( "profilingStartTime" , & start) ?;
1519+ map. serialize_entry ( "profilingEndTime" , & end) ?;
1520+ }
1521+
15001522 map. serialize_entry ( "symbolicated" , & self . 0 . symbolicated ) ?;
15011523 map. serialize_entry ( "pausedRanges" , & [ ] as & [ ( ) ] ) ?;
15021524 map. serialize_entry ( "version" , & 24 ) ?; // this version is ignored, only "preprocessedProfileVersion" is used
Original file line number Diff line number Diff line change @@ -105,6 +105,10 @@ impl SampleTable {
105105 self . sample_weight_type = t;
106106 }
107107
108+ pub fn timestamps ( & self ) -> impl Iterator < Item = Timestamp > + use < ' _ > {
109+ self . sample_timestamps . iter ( ) . copied ( )
110+ }
111+
108112 pub fn modify_last_sample ( & mut self , timestamp : Timestamp , weight : i32 ) {
109113 * self . sample_weights . last_mut ( ) . unwrap ( ) += weight;
110114 * self . sample_timestamps . last_mut ( ) . unwrap ( ) = timestamp;
Original file line number Diff line number Diff line change @@ -194,6 +194,18 @@ impl Thread {
194194 self . frame_interner . gather_used_rvas ( collector) ;
195195 }
196196
197+ pub fn sample_timestamps ( & self ) -> impl Iterator < Item = Timestamp > + use < ' _ > {
198+ self . samples . timestamps ( )
199+ }
200+
201+ pub fn marker_start_times ( & self ) -> impl Iterator < Item = Timestamp > + use < ' _ > {
202+ self . markers . start_times ( )
203+ }
204+
205+ pub fn marker_end_times ( & self ) -> impl Iterator < Item = Timestamp > + use < ' _ > {
206+ self . markers . end_times ( )
207+ }
208+
197209 pub fn cmp_for_json_order ( & self , other : & Thread ) -> Ordering {
198210 let ordering = ( !self . is_main ) . cmp ( & ( !other. is_main ) ) ;
199211 if ordering != Ordering :: Equal {
Original file line number Diff line number Diff line change @@ -344,6 +344,8 @@ fn profile_without_js() {
344344 "time" : "ms"
345345 } ,
346346 "startTime" : 1636162232627.0 ,
347+ "profilingStartTime" : 0.0 ,
348+ "profilingEndTime" : 3.0 ,
347349 "symbolicated" : false ,
348350 "pausedRanges" : [ ] ,
349351 "version" : 24 ,
@@ -1020,6 +1022,8 @@ fn profile_with_js() {
10201022 "time" : "ms"
10211023 } ,
10221024 "startTime" : 1636162232627.0 ,
1025+ "profilingStartTime" : 1.0 ,
1026+ "profilingEndTime" : 1.0 ,
10231027 "symbolicated" : false ,
10241028 "pausedRanges" : [ ] ,
10251029 "version" : 24 ,
@@ -1277,6 +1281,8 @@ fn profile_counters_with_sorted_processes() {
12771281 "time" : "ms"
12781282 } ,
12791283 "startTime" : 1636162232627.0 ,
1284+ "profilingStartTime" : 0.0 ,
1285+ "profilingEndTime" : 1.0 ,
12801286 "symbolicated" : true ,
12811287 "pausedRanges" : [ ] ,
12821288 "version" : 24 ,
@@ -1590,6 +1596,8 @@ fn test_flow_marker_fields() {
15901596 "time" : "ms"
15911597 } ,
15921598 "startTime" : 1636162232627.0 ,
1599+ "profilingStartTime" : 10.0 ,
1600+ "profilingEndTime" : 10.0 ,
15931601 "symbolicated" : false ,
15941602 "pausedRanges" : [ ] ,
15951603 "version" : 24 ,
You can’t perform that action at this time.
0 commit comments