aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2006-03-15 06:44:35 +0000
committerChristian Grothoff <christian@grothoff.org>2006-03-15 06:44:35 +0000
commit92c72a38874bb4fd54bc97ffc9c241947bc4860c (patch)
tree2839b880e6460838f00e6689a2bdd53d222067e5
parent91574251fe4a5d386a3226e647a89e73a479e101 (diff)
downloadgnunet-gtk-92c72a38874bb4fd54bc97ffc9c241947bc4860c.tar.gz
gnunet-gtk-92c72a38874bb4fd54bc97ffc9c241947bc4860c.zip
fixing Mantis 1003
-rw-r--r--src/plugins/stats/functions.c22
-rw-r--r--src/plugins/stats/statistics.c55
2 files changed, 57 insertions, 20 deletions
diff --git a/src/plugins/stats/functions.c b/src/plugins/stats/functions.c
index b595c81f..b747da7a 100644
--- a/src/plugins/stats/functions.c
+++ b/src/plugins/stats/functions.c
@@ -115,7 +115,7 @@ static int getConnectedNodesStat(const void * closure,
115 NULL, 115 NULL,
116 "# of connected peers")) 116 "# of connected peers"))
117 return SYSERR; 117 return SYSERR;
118 data[0][0] = 0.8 * val / connectionGoal; 118 data[0][0] = ((gfloat) val) / connectionGoal;
119 return OK; 119 return OK;
120} 120}
121 121
@@ -128,7 +128,7 @@ static int getCPULoadStat(const void * closure,
128 NULL, 128 NULL,
129 "% of allowed cpu load")) 129 "% of allowed cpu load"))
130 return SYSERR; 130 return SYSERR;
131 data[0][0] = val / 125.0; 131 data[0][0] = (gfloat) val / 100.0;
132 return OK; 132 return OK;
133} 133}
134 134
@@ -196,10 +196,10 @@ static int getTrafficRecvStats(const void * closure,
196 data[0][3] = 0.0; 196 data[0][3] = 0.0;
197 return OK; 197 return OK;
198 } 198 }
199 data[0][0] = 0.8 * noise / (banddown * dtime / cronSECONDS); /* red */ 199 data[0][0] = ((gfloat) noise) / (banddown * dtime / cronSECONDS); /* red */
200 data[0][1] = 0.8 * (content+noise) / (banddown * dtime / cronSECONDS); /* green */ 200 data[0][1] = ((gfloat) (content+noise)) / (banddown * dtime / cronSECONDS); /* green */
201 data[0][2] = 0.8 * (queries+content+noise) / (banddown * dtime / cronSECONDS); /* yellow */ 201 data[0][2] = ((gfloat)(queries+content+noise)) / (banddown * dtime / cronSECONDS); /* yellow */
202 data[0][3] = 0.8 * total / (banddown * dtime / cronSECONDS); /* blue */ 202 data[0][3] = ((gfloat) total) / (banddown * dtime / cronSECONDS); /* blue */
203 /*printf("I: %f %f %f\n", 203 /*printf("I: %f %f %f\n",
204 data[0][0], 204 data[0][0],
205 data[0][1], 205 data[0][1],
@@ -248,7 +248,7 @@ static int getTrafficSendStats(const void * closure,
248 i = 0; 248 i = 0;
249 SNPRINTF(buffer, 249 SNPRINTF(buffer,
250 512, 250 512,
251 "# bytes received of type %d", 251 "# bytes transmitted of type %d",
252 P2P_PROTO_gap_QUERY); 252 P2P_PROTO_gap_QUERY);
253 if (OK != getStatValue(&queries, 253 if (OK != getStatValue(&queries,
254 &lqueries, 254 &lqueries,
@@ -271,10 +271,10 @@ static int getTrafficSendStats(const void * closure,
271 data[0][3] = 0.0; 271 data[0][3] = 0.0;
272 return OK; 272 return OK;
273 } 273 }
274 data[0][0] = 0.8 * noise / (bandup * dtime / cronSECONDS); /* red */ 274 data[0][0] = ((gfloat) noise) / (bandup * dtime / cronSECONDS); /* red */
275 data[0][1] = 0.8 * (noise + content) / (bandup*dtime / cronSECONDS); /* green */ 275 data[0][1] = ((gfloat) (noise + content)) / (bandup*dtime / cronSECONDS); /* green */
276 data[0][2] = 0.8 * (noise + content + queries) / (bandup*dtime / cronSECONDS); /* yellow */ 276 data[0][2] = ((gfloat) (noise + content + queries)) / (bandup*dtime / cronSECONDS); /* yellow */
277 data[0][3] = 0.8 * total / (bandup*dtime / cronSECONDS); /* blue */ 277 data[0][3] = ((gfloat) total) / (bandup*dtime / cronSECONDS); /* blue */
278 /* printf("O: %f %f %f\n", 278 /* printf("O: %f %f %f\n",
279 data[0][0], 279 data[0][0],
280 data[0][1], 280 data[0][1],
diff --git a/src/plugins/stats/statistics.c b/src/plugins/stats/statistics.c
index db44f720..2ea19cb5 100644
--- a/src/plugins/stats/statistics.c
+++ b/src/plugins/stats/statistics.c
@@ -67,6 +67,8 @@ static void load_graph_draw(LoadGraph *g) {
67 guint j; 67 guint j;
68 gint dely; 68 gint dely;
69 float delx; 69 float delx;
70 float max;
71 GdkFont * font;
70 72
71 if (!g->disp->window) 73 if (!g->disp->window)
72 return; 74 return;
@@ -111,13 +113,48 @@ static void load_graph_draw(LoadGraph *g) {
111 g->draw_width, 113 g->draw_width,
112 g->disp->allocation.height); 114 g->disp->allocation.height);
113 115
114 dely = g->draw_height / 5; 116 max = 0.26; /* force showing at least the 25% line */
115 for (i = 1; i <5; i++) { 117 for (i = 0; i < g->num_points - 1; i++)
118 for (j=0;j<g->count;j++)
119 if (g->data[i][j] > max)
120 max = g->data[i][j];
121 max = max * 1.01; /* leave top 1% free */
122
123 font = gdk_font_load("fixed"); /* deprecated, but pango is far more than
124 what we need here -- fix later? */
125 /* draw lines at 25%, 50%, 75% and 100% of max */
126 dely = g->draw_height / max / 4;
127 for (i = 1; i < 5; i++) {
116 gint y1 = g->draw_height + 1 - i * dely; 128 gint y1 = g->draw_height + 1 - i * dely;
117 gdk_draw_line (g->pixmap, g->gc, 129 if ( (dely < 30) && (i != 4) )
118 0, y1, g->draw_width, y1); 130 continue; /* only print additional
131 lines if there is enough space! */
132 if (y1 > 0) {
133 const gchar * label[] = {
134 NULL,
135 " 25%",
136 " 50%",
137 " 75%",
138 "100%",
139 };
140 gdk_draw_string(g->pixmap,
141 font,
142 g->gc,
143 10,
144 y1 - 8,
145 label[i]);
146 gdk_draw_line (g->pixmap, g->gc,
147 0, y1, g->draw_width, y1);
148 if (i == 4) {
149 /* extra-thick line at 100% */
150 gdk_draw_line (g->pixmap, g->gc,
151 0, y1 - 1, g->draw_width, y1 - 1);
152 gdk_draw_line (g->pixmap, g->gc,
153 0, y1 + 1, g->draw_width, y1 + 1);
154
155 }
156 }
119 } 157 }
120
121 gdk_gc_set_line_attributes(g->gc, 158 gdk_gc_set_line_attributes(g->gc,
122 2, 159 2,
123 GDK_LINE_SOLID, 160 GDK_LINE_SOLID,
@@ -130,8 +167,8 @@ static void load_graph_draw(LoadGraph *g) {
130 for (i = 0; i < g->num_points - 1; i++) { 167 for (i = 0; i < g->num_points - 1; i++) {
131 gint x1 = i * delx; 168 gint x1 = i * delx;
132 gint x2 = (i + 1) * delx; 169 gint x2 = (i + 1) * delx;
133 gint y1 = g->data[i][j] * g->draw_height - 1; 170 gint y1 = g->data[i][j] / max * g->draw_height - 1;
134 gint y2 = g->data[i+1][j] * g->draw_height - 1; 171 gint y2 = g->data[i+1][j] / max * g->draw_height - 1;
135 172
136 if ((g->data[i][j] != -1) && (g->data[i+1][j] != -1)) { 173 if ((g->data[i][j] != -1) && (g->data[i+1][j] != -1)) {
137 if (stats[g->statIdx].fill == NO) { 174 if (stats[g->statIdx].fill == NO) {
@@ -153,8 +190,8 @@ static void load_graph_draw(LoadGraph *g) {
153 points[2].y = g->draw_height; 190 points[2].y = g->draw_height;
154 points[3].y = g->draw_height; 191 points[3].y = g->draw_height;
155 } else { 192 } else {
156 gint ly1 = g->data[i][j-1] * g->draw_height - 1; 193 gint ly1 = g->data[i][j-1] / max * g->draw_height - 1;
157 gint ly2 = g->data[i+1][j-1] * g->draw_height - 1; 194 gint ly2 = g->data[i+1][j-1] / max * g->draw_height - 1;
158 points[2].y = g->draw_height - ly1; 195 points[2].y = g->draw_height - ly1;
159 points[3].y = g->draw_height - ly2; 196 points[3].y = g->draw_height - ly2;
160 } 197 }