Use an indirect pointer to min/max entry rather than value

This way we can always find the actual min/max entry that generated the
local minima/maxima.  Which is useful for visualization.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2011-09-08 15:59:04 -07:00
parent a13d3172fa
commit 28cadad144

View file

@ -32,8 +32,8 @@ struct plot_info {
int sec; int sec;
int val; int val;
int smoothed; int smoothed;
int min[3]; struct plot_data *min[3];
int max[3]; struct plot_data *max[3];
int avg[3]; int avg[3];
} entry[]; } entry[];
}; };
@ -255,13 +255,13 @@ static void plot_minmax_profile_minute(struct graphics_context *gc, struct plot_
struct plot_data *entry = pi->entry; struct plot_data *entry = pi->entry;
cairo_set_source_rgba(gc->cr, 1, 0.2, 1, a); cairo_set_source_rgba(gc->cr, 1, 0.2, 1, a);
move_to(gc, entry->sec, entry->min[index]); move_to(gc, entry->sec, entry->min[index]->val);
for (i = 1; i < pi->nr; i++) { for (i = 1; i < pi->nr; i++) {
entry++; entry++;
line_to(gc, entry->sec, entry->min[index]); line_to(gc, entry->sec, entry->min[index]->val);
} }
for (i = 1; i < pi->nr; i++) { for (i = 1; i < pi->nr; i++) {
line_to(gc, entry->sec, entry->max[index]); line_to(gc, entry->sec, entry->max[index]->val);
entry--; entry--;
} }
cairo_close_path(gc->cr); cairo_close_path(gc->cr);
@ -504,8 +504,9 @@ static void analyze_plot_info_minmax_minute(struct plot_data *entry, struct plot
{ {
struct plot_data *p = entry; struct plot_data *p = entry;
int time = entry->sec; int time = entry->sec;
int seconds = 60*(index+1); int seconds = 90*(index+1);
int min, max, avg, nr; struct plot_data *min, *max;
int avg, nr;
/* Go back 'seconds' in time */ /* Go back 'seconds' in time */
while (p > first) { while (p > first) {
@ -515,7 +516,8 @@ static void analyze_plot_info_minmax_minute(struct plot_data *entry, struct plot
} }
/* Then go forward until we hit an entry past the time */ /* Then go forward until we hit an entry past the time */
min = max = avg = p->val; min = max = p;
avg = p->val;
nr = 1; nr = 1;
while (++p < last) { while (++p < last) {
int val = p->val; int val = p->val;
@ -523,10 +525,10 @@ static void analyze_plot_info_minmax_minute(struct plot_data *entry, struct plot
break; break;
avg += val; avg += val;
nr ++; nr ++;
if (val < min) if (val < min->val)
min = val; min = p;
if (val > max) if (val > max->val)
max = val; max = p;
} }
entry->min[index] = min; entry->min[index] = min;
entry->max[index] = max; entry->max[index] = max;