@@ -204,22 +204,32 @@ PerformanceMeasure PerformanceEntryReporter::reportMeasure(
204204 const std::optional<std::string>& endMark,
205205 const std::optional<jsinspector_modern::DevToolsTrackEntryPayload>&
206206 trackMetadata) {
207- DOMHighResTimeStamp startTimeVal =
208- startMark ? getMarkTime (*startMark) : startTime;
209- DOMHighResTimeStamp endTimeVal = endMark ? getMarkTime (*endMark) : endTime;
207+ DOMHighResTimeStamp startTimeValue = startTime;
208+ if (startMark) {
209+ if (auto startMarkBufferedTime = getMarkTime (*startMark)) {
210+ startTimeValue = *startMarkBufferedTime;
211+ }
212+ }
213+
214+ DOMHighResTimeStamp endTimeValue = endTime;
215+ if (endMark) {
216+ if (auto endMarkBufferedTime = getMarkTime (*endMark)) {
217+ endTimeValue = *endMarkBufferedTime;
218+ }
219+ }
210220
211- if (!endMark && endTime < startTimeVal ) {
221+ if (!endMark && endTime < startTimeValue ) {
212222 // The end time is not specified, take the current time, according to the
213223 // standard
214- endTimeVal = getCurrentTimeStamp ();
224+ endTimeValue = getCurrentTimeStamp ();
215225 }
216226
217227 DOMHighResTimeStamp durationVal =
218- duration ? *duration : endTimeVal - startTimeVal ;
228+ duration ? *duration : endTimeValue - startTimeValue ;
219229
220230 const auto entry = PerformanceMeasure{
221231 {.name = std::string (name),
222- .startTime = startTimeVal ,
232+ .startTime = startTimeValue ,
223233 .duration = durationVal}};
224234
225235 traceMeasure (entry);
@@ -235,16 +245,16 @@ PerformanceMeasure PerformanceEntryReporter::reportMeasure(
235245 return entry;
236246}
237247
238- DOMHighResTimeStamp PerformanceEntryReporter::getMarkTime (
248+ std::optional< DOMHighResTimeStamp> PerformanceEntryReporter::getMarkTime (
239249 const std::string& markName) const {
240250 std::shared_lock lock (buffersMutex_);
241251
242252 if (auto it = markBuffer_.find (markName); it) {
243253 return std::visit (
244254 [](const auto & entryData) { return entryData.startTime ; }, *it);
245- } else {
246- return 0.0 ;
247255 }
256+
257+ return std::nullopt ;
248258}
249259
250260void PerformanceEntryReporter::reportEvent (
0 commit comments