@@ -31,7 +31,7 @@ use crate::sample_table::WeightType;
31
31
use crate :: string_table:: { GlobalStringIndex , GlobalStringTable } ;
32
32
use crate :: thread:: { ProcessHandle , Thread } ;
33
33
use crate :: timestamp:: Timestamp ;
34
- use crate :: { FrameFlags , Symbol } ;
34
+ use crate :: { FrameFlags , PlatformSpecificReferenceTimestamp , Symbol } ;
35
35
36
36
/// The sampling interval used during profile recording.
37
37
///
@@ -181,6 +181,7 @@ pub struct Profile {
181
181
pub ( crate ) initial_visible_threads : Vec < ThreadHandle > ,
182
182
pub ( crate ) initial_selected_threads : Vec < ThreadHandle > ,
183
183
pub ( crate ) reference_timestamp : ReferenceTimestamp ,
184
+ pub ( crate ) platform_specific_reference_timestamp : Option < PlatformSpecificReferenceTimestamp > ,
184
185
pub ( crate ) string_table : GlobalStringTable ,
185
186
pub ( crate ) marker_schemas : Vec < InternalMarkerSchema > ,
186
187
static_schema_marker_types : FastHashMap < & ' static str , MarkerTypeHandle > ,
@@ -214,6 +215,7 @@ impl Profile {
214
215
global_libs : GlobalLibTable :: new ( ) ,
215
216
kernel_libs : LibMappings :: new ( ) ,
216
217
reference_timestamp,
218
+ platform_specific_reference_timestamp : None ,
217
219
processes : Vec :: new ( ) ,
218
220
string_table : GlobalStringTable :: new ( ) ,
219
221
marker_schemas : Vec :: new ( ) ,
@@ -236,6 +238,14 @@ impl Profile {
236
238
self . reference_timestamp = reference_timestamp;
237
239
}
238
240
241
+ /// Set an additional reference timestamp with a platform-specific unit.
242
+ pub fn set_platform_specific_reference_timestamp (
243
+ & mut self ,
244
+ platform_specific_reference_timestamp : PlatformSpecificReferenceTimestamp ,
245
+ ) {
246
+ self . platform_specific_reference_timestamp = Some ( platform_specific_reference_timestamp) ;
247
+ }
248
+
239
249
/// Change the product name.
240
250
pub fn set_product ( & mut self , product : & str ) {
241
251
self . product = product. to_string ( ) ;
@@ -1355,6 +1365,18 @@ impl Serialize for SerializableProfileMeta<'_> {
1355
1365
} ) ,
1356
1366
) ?;
1357
1367
map. serialize_entry ( "startTime" , & self . 0 . reference_timestamp ) ?;
1368
+ match & self . 0 . platform_specific_reference_timestamp {
1369
+ Some ( PlatformSpecificReferenceTimestamp :: ClockMonotonicNanosecondsSinceBoot ( val) ) => {
1370
+ map. serialize_entry ( "startTimeAsClockMonotonicNanosecondsSinceBoot" , & val) ?;
1371
+ }
1372
+ Some ( PlatformSpecificReferenceTimestamp :: MachAbsoluteTimeNanoseconds ( val) ) => {
1373
+ map. serialize_entry ( "startTimeAsMachAbsoluteTimeNanoseconds" , & val) ?;
1374
+ }
1375
+ Some ( PlatformSpecificReferenceTimestamp :: QueryPerformanceCounterValue ( val) ) => {
1376
+ map. serialize_entry ( "startTimeAsQueryPerformanceCounterValue" , & val) ?;
1377
+ }
1378
+ None => { }
1379
+ }
1358
1380
map. serialize_entry ( "symbolicated" , & self . 0 . symbolicated ) ?;
1359
1381
map. serialize_entry ( "pausedRanges" , & [ ] as & [ ( ) ] ) ?;
1360
1382
map. serialize_entry ( "version" , & 24 ) ?; // this version is ignored, only "preprocessedProfileVersion" is used
0 commit comments