aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2016-02-09 22:16:17 -0500
committerSteven Rostedt <rostedt@goodmis.org>2016-02-09 22:16:17 -0500
commit0999a66c81dd056ae791b259704c1d616a26c8ca (patch)
treefcc8bdba12266f58e232875536bb45934fccc6f3
parente181db31dfac813124e59db0ebe19a7af7a9df24 (diff)
downloadtrace-cmd-0999a66c81dd056ae791b259704c1d616a26c8ca.tar.gz
kernelshark: Time the drawing of the graph
In order to find ways to optimize the drawing of the graph when there are millions of events, time how long it takes to draw. If TIME_DRAW is set then print the result. This may later turn into a debug option as well. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-graph.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/trace-graph.c b/trace-graph.c
index 9c92fc27..4e0dd6ed 100644
--- a/trace-graph.c
+++ b/trace-graph.c
@@ -24,6 +24,8 @@
#include <unistd.h>
#include <gtk/gtk.h>
+#include <sys/time.h>
+
#include "trace-compat.h"
#include "trace-cmd.h"
#include "trace-local.h"
@@ -45,6 +47,8 @@
# define dprintf(l, x...) do { if (0) printf(x); } while (0)
#endif
+#define TIME_DRAW 0
+
#define MAX_WIDTH 10000
#define PLOT_SIZE 10
@@ -1805,6 +1809,7 @@ static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot,
static void draw_plots(struct graph_info *ginfo, gint new_width)
{
+ struct timeval tv_start, tv_stop;
struct plot_list *list;
struct graph_plot *plot;
struct pevent_record *record;
@@ -1835,6 +1840,7 @@ static void draw_plots(struct graph_info *ginfo, gint new_width)
tracecmd_set_all_cpus_to_timestamp(ginfo->handle,
ginfo->view_start_time);
+ gettimeofday(&tv_start, NULL);
trace_set_cursor(GDK_WATCH);
/* Shortcut if we don't have any task plots */
@@ -1896,6 +1902,14 @@ out:
plot->gc = NULL;
}
trace_put_cursor();
+ gettimeofday(&tv_stop, NULL);
+ if (tv_start.tv_usec > tv_stop.tv_usec) {
+ tv_stop.tv_usec += 1000000;
+ tv_stop.tv_sec--;
+ }
+ if (TIME_DRAW)
+ printf("Time to draw: %ld.%06ld\n", tv_stop.tv_sec - tv_start.tv_sec,
+ tv_stop.tv_usec - tv_start.tv_usec);
}