aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-12-31 00:57:06 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-12-31 00:57:06 -0500
commit2224bbf5ad3178e9555a2d79805e73a4193ec61f (patch)
treec3f3817ef3d89397b81908f4bd306ae29ddb4bff
parentf84bc1f92e9e6430fd50569ddde22b136f723bd8 (diff)
trace-graph: Add a little better pid hash function
This adds a little better pid hash function that will give a better difference in colors for tasks than the previous hash algorithm. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-graph.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/trace-graph.c b/trace-graph.c
index 7044fac..8692fe7 100644
--- a/trace-graph.c
+++ b/trace-graph.c
@@ -735,9 +735,27 @@ button_release_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
735 735
736static gint do_hash(gint val) 736static gint do_hash(gint val)
737{ 737{
738 return (val + (val << 4) + (val << 8) + (val << 12) + 738 int i, x, y;
739 (val << 16) + (val << 20) + (val << 24) + 739 int total = 0;
740 (val << 28)) * 3; 740
741 if (!val)
742 return 0;
743
744 for (i = 0; i < 32; i++) {
745 y = 0;
746 if (val & (1 << i)) {
747 for (x = 0; x < ((i+1) * 13); x++) {
748 y |= 1 << ((x * 23) & 31);
749 }
750 } else {
751 for (x = 0; x < ((i+1) * 7); x++) {
752 y |= 1 << ((x * 17) & 31);
753 }
754 }
755 total += y;
756 }
757
758 return total;
741} 759}
742 760
743static void set_color_by_pid(GtkWidget *widget, GdkGC *gc, gint pid) 761static void set_color_by_pid(GtkWidget *widget, GdkGC *gc, gint pid)
@@ -901,9 +919,9 @@ static void draw_cpu(struct graph_info *ginfo, gint cpu,
901 919
902 last_x = x; 920 last_x = x;
903 last_pid = pid; 921 last_pid = pid;
904 }
905 922
906 set_color_by_pid(ginfo->draw, gc, pid); 923 set_color_by_pid(ginfo->draw, gc, pid);
924 }
907 925
908 gdk_draw_line(ginfo->curr_pixmap, gc, // ginfo->draw->style->black_gc, 926 gdk_draw_line(ginfo->curr_pixmap, gc, // ginfo->draw->style->black_gc,
909 x, CPU_TOP(cpu), x, CPU_BOTTOM(cpu)); 927 x, CPU_TOP(cpu), x, CPU_BOTTOM(cpu));