[sysprof] libsysprof-capture: discover the end time if necessary
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof-capture: discover the end time if necessary
- Date: Wed, 29 May 2019 22:32:52 +0000 (UTC)
commit 8feeec782fe4d5c3b2143c7ded2f23a8746a9363
Author: Christian Hergert <chergert redhat com>
Date: Fri May 17 11:11:39 2019 -0700
libsysprof-capture: discover the end time if necessary
If we get a capture file without a valid end-time, we should just go
discover that up-front instead of dealing with it all over the place.
src/libsysprof-capture/sysprof-capture-reader.c | 36 +++++++++++++++++++++++++
1 file changed, 36 insertions(+)
---
diff --git a/src/libsysprof-capture/sysprof-capture-reader.c b/src/libsysprof-capture/sysprof-capture-reader.c
index f81607f..c22d3bb 100644
--- a/src/libsysprof-capture/sysprof-capture-reader.c
+++ b/src/libsysprof-capture/sysprof-capture-reader.c
@@ -109,6 +109,35 @@ sysprof_capture_reader_get_filename (SysprofCaptureReader *self)
return self->filename;
}
+static void
+sysprof_capture_reader_discover_end_time (SysprofCaptureReader *self)
+{
+ SysprofCaptureFrame frame;
+
+ g_assert (self != NULL);
+
+ while (sysprof_capture_reader_peek_frame (self, &frame))
+ {
+ gint64 end_time = frame.time;
+
+ if (frame.type == SYSPROF_CAPTURE_FRAME_MARK)
+ {
+ const SysprofCaptureMark *mark = NULL;
+
+ if ((mark = sysprof_capture_reader_read_mark (self)))
+ end_time = frame.time + MAX (0, mark->duration);
+ }
+
+ if (end_time > self->end_time)
+ self->end_time = end_time;
+
+ if (!sysprof_capture_reader_skip (self))
+ break;
+ }
+
+ sysprof_capture_reader_reset (self);
+}
+
/**
* sysprof_capture_reader_new_from_fd:
* @fd: an fd to take ownership from
@@ -148,6 +177,13 @@ sysprof_capture_reader_new_from_fd (int fd,
else
self->endian = G_BIG_ENDIAN;
+ /* If we detect a capture file that did not get an end time, or an erroneous
+ * end time, then we need to take a performance hit here and scan the file
+ * and discover the end time with frame timings.
+ */
+ if (self->header.end_time < self->header.time)
+ sysprof_capture_reader_discover_end_time (self);
+
return self;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]