mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-12 18:36:15 +00:00
overlay: Scale the CPU busy value by the numer of active cores
Having 100% always mean one processor fully utilised is much easier to understand (than having to remember how many cores are on each machine and scale appropriately). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
177208b0d4
commit
c6b26c5a40
@ -25,10 +25,20 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "cpu-top.h"
|
#include "cpu-top.h"
|
||||||
|
|
||||||
|
int cpu_top_init(struct cpu_top *cpu)
|
||||||
|
{
|
||||||
|
memset(cpu, 0, sizeof(*cpu));
|
||||||
|
|
||||||
|
cpu->nr_cpu = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int cpu_top_update(struct cpu_top *cpu)
|
int cpu_top_update(struct cpu_top *cpu)
|
||||||
{
|
{
|
||||||
struct cpu_stat *s = &cpu->stat[cpu->count++&1];
|
struct cpu_stat *s = &cpu->stat[cpu->count++&1];
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
struct cpu_top {
|
struct cpu_top {
|
||||||
uint8_t busy;
|
uint8_t busy;
|
||||||
|
int nr_cpu;
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
struct cpu_stat {
|
struct cpu_stat {
|
||||||
@ -37,6 +38,7 @@ struct cpu_top {
|
|||||||
} stat[2];
|
} stat[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int cpu_top_init(struct cpu_top *cpu);
|
||||||
int cpu_top_update(struct cpu_top *cpu);
|
int cpu_top_update(struct cpu_top *cpu);
|
||||||
|
|
||||||
#endif /* CPU_TOP_H */
|
#endif /* CPU_TOP_H */
|
||||||
|
@ -143,8 +143,8 @@ static void init_gpu_top(struct overlay_context *ctx,
|
|||||||
};
|
};
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
|
cpu_top_init(>->cpu_top);
|
||||||
gpu_top_init(>->gpu_top);
|
gpu_top_init(>->gpu_top);
|
||||||
memset(>->cpu, 0, sizeof(gt->cpu));
|
|
||||||
|
|
||||||
chart_init(>->cpu, "CPU", 120);
|
chart_init(>->cpu, "CPU", 120);
|
||||||
chart_set_position(>->cpu, PAD, PAD);
|
chart_set_position(>->cpu, PAD, PAD);
|
||||||
@ -222,7 +222,7 @@ static void show_gpu_top(struct overlay_context *ctx, struct overlay_gpu_top *gt
|
|||||||
y = PAD + 12 - 2;
|
y = PAD + 12 - 2;
|
||||||
cairo_set_source_rgba(ctx->cr, 0.75, 0.25, 0.75, 1.);
|
cairo_set_source_rgba(ctx->cr, 0.75, 0.25, 0.75, 1.);
|
||||||
cairo_move_to(ctx->cr, PAD, y);
|
cairo_move_to(ctx->cr, PAD, y);
|
||||||
sprintf(txt, "CPU: %3d%% busy", gt->cpu_top.busy);
|
sprintf(txt, "CPU: %3d%% busy", gt->cpu_top.busy * gt->cpu_top.nr_cpu);
|
||||||
cairo_show_text(ctx->cr, txt);
|
cairo_show_text(ctx->cr, txt);
|
||||||
y += 14;
|
y += 14;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user