From: Umut Tezduyar Date: Wed, 8 May 2013 12:29:12 +0000 (+0200) Subject: analyze: show generators on plot X-Git-Tag: v205~180 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=518d10e98508ec8181e864924484a2ca994c5d43;hp=6351163bf3e519cc07adb2732d12450741f5a0d3 analyze: show generators on plot --- diff --git a/src/analyze/systemd-analyze.c b/src/analyze/systemd-analyze.c index bb86ec7da..df3d30724 100644 --- a/src/analyze/systemd-analyze.c +++ b/src/analyze/systemd-analyze.c @@ -78,6 +78,8 @@ struct boot_times { usec_t initrd_time; usec_t userspace_time; usec_t finish_time; + usec_t generators_start_time; + usec_t generators_finish_time; }; struct unit_times { char *name; @@ -303,7 +305,17 @@ static int acquire_boot_times(DBusConnection *bus, struct boot_times **bt) { "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "FinishTimestampMonotonic", - ×.finish_time) < 0) + ×.finish_time) < 0 || + bus_get_uint64_property(bus, + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "GeneratorsStartTimestampMonotonic", + ×.generators_start_time) < 0 || + bus_get_uint64_property(bus, + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "GeneratorsFinishTimestampMonotonic", + ×.generators_finish_time) < 0) return -EIO; if (times.finish_time <= 0) { @@ -459,7 +471,8 @@ static int analyze_plot(DBusConnection *bus) { svg("\n\n", - 80.0 + width, 150.0 + (m * SCALE_Y)); + 80.0 + width, 150.0 + (m * SCALE_Y) + + 4 * SCALE_Y /* legend */); /* write some basic info as a comment, including some help */ svg("\n" @@ -480,6 +493,7 @@ static int analyze_plot(DBusConnection *bus) { " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" + " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" " line { stroke: rgb(64,64,64); stroke-width: 1; }\n" "// line.sec1 { }\n" @@ -495,8 +509,6 @@ static int analyze_plot(DBusConnection *bus) { svg("%s %s (%s %s) %s", isempty(osname) ? "Linux" : osname, name.nodename, name.release, name.version, name.machine); - svg("Legend: Red = Activating; Pink = Active; Dark Pink = Deactivating", - 120.0 + (m *SCALE_Y)); svg("\n", 20.0 + (SCALE_X * boot->firmware_time)); svg_graph_box(m, -boot->firmware_time, boot->finish_time); @@ -521,8 +533,9 @@ static int analyze_plot(DBusConnection *bus) { svg_text(true, boot->initrd_time, y, "initrd"); y++; } - svg_bar("userspace", boot->userspace_time, boot->finish_time, y); - svg_text("left", boot->userspace_time, y, "userspace"); + svg_bar("active", boot->userspace_time, boot->finish_time, y); + svg_bar("generators", boot->generators_start_time, boot->generators_finish_time, y); + svg_text("left", boot->userspace_time, y, "systemd"); y++; for (u = times; u < times + n; u++) { @@ -544,6 +557,23 @@ static int analyze_plot(DBusConnection *bus) { svg_text(b, u->ixt, y, "%s", u->name); y++; } + + /* Legend */ + y++; + svg_bar("activating", 0, 300000, y); + svg_text("right", 400000, y, "Activating"); + y++; + svg_bar("active", 0, 300000, y); + svg_text("right", 400000, y, "Active"); + y++; + svg_bar("deactivating", 0, 300000, y); + svg_text("right", 400000, y, "Deactivating"); + y++; + svg_bar("generators", 0, 300000, y); + svg_text("right", 400000, y, "Generators"); + y++; + + svg("\n\n"); svg(""); diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index f3ddfc976..988c06aa4 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -282,6 +282,10 @@ " \n" \ " \n" \ " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ @@ -587,6 +591,10 @@ static const BusProperty bus_manager_properties[] = { { "UserspaceTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, userspace_timestamp.monotonic) }, { "FinishTimestamp", bus_property_append_uint64, "t", offsetof(Manager, finish_timestamp.realtime) }, { "FinishTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, finish_timestamp.monotonic) }, + { "GeneratorsStartTimestamp", bus_property_append_uint64, "t", offsetof(Manager, generators_start_timestamp.realtime) }, + { "GeneratorsStartTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, generators_start_timestamp.monotonic) }, + { "GeneratorsFinishTimestamp", bus_property_append_uint64, "t", offsetof(Manager, generators_finish_timestamp.realtime) }, + { "GeneratorsFinishTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, generators_finish_timestamp.monotonic) }, { "LogLevel", bus_manager_append_log_level, "s", 0, false, bus_manager_set_log_level }, { "LogTarget", bus_manager_append_log_target, "s", 0, false, bus_manager_set_log_target }, { "NNames", bus_manager_append_n_names, "u", 0 }, diff --git a/src/core/manager.c b/src/core/manager.c index 6b0f56766..73f4c102e 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -826,7 +826,9 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) { assert(m); + dual_timestamp_get(&m->generators_start_timestamp); manager_run_generators(m); + dual_timestamp_get(&m->generators_finish_timestamp); r = lookup_paths_init( &m->lookup_paths, m->running_as, true, diff --git a/src/core/manager.h b/src/core/manager.h index bf833540a..5d777e6ed 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -150,6 +150,8 @@ struct Manager { dual_timestamp initrd_timestamp; dual_timestamp userspace_timestamp; dual_timestamp finish_timestamp; + dual_timestamp generators_start_timestamp; + dual_timestamp generators_finish_timestamp; char *generator_unit_path; char *generator_unit_path_early;