forked from enlightenment/evisum
cpu: rudimentary order by topology...
This commit is contained in:
parent
3ec2144f89
commit
5db5da933c
|
@ -113,6 +113,9 @@ system_cpu_temperature_min_max_get(int *min, int *max);
|
|||
int
|
||||
system_cpu_frequency_min_max_get(int *min, int *max);
|
||||
|
||||
void
|
||||
system_cpu_topology_get(int *ids, int ncpus);
|
||||
|
||||
void
|
||||
system_memory_usage_get(meminfo_t *memory);
|
||||
|
||||
|
|
|
@ -279,7 +279,6 @@ system_cpu_usage_get(int *ncpu)
|
|||
return system_cpu_usage_delayed_get(ncpu, 1000000);
|
||||
}
|
||||
|
||||
|
||||
static int _cpu_temp_min = 0;
|
||||
static int _cpu_temp_max = 100;
|
||||
static char _core_temps[256][512];
|
||||
|
@ -596,3 +595,53 @@ system_cpu_frequency_get(void)
|
|||
#endif
|
||||
return freq;
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
|
||||
typedef struct {
|
||||
short id;
|
||||
short core_id;
|
||||
} core_top_t;
|
||||
|
||||
static int
|
||||
_cmp(const void *a, const void *b)
|
||||
{
|
||||
core_top_t *aa = (core_top_t *) a;
|
||||
core_top_t *bb = (core_top_t *) b;
|
||||
|
||||
if (aa->core_id == bb->core_id) return 0;
|
||||
else if (aa->core_id < bb->core_id) return -1;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
system_cpu_topology_get(int *ids, int ncpu)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
char buf[4096];
|
||||
core_top_t *cores = malloc(ncpu * sizeof(core_top_t));
|
||||
|
||||
for (int i = 0; i < ncpu; i++)
|
||||
{
|
||||
cores[i].id = i;
|
||||
cores[i].core_id = i;
|
||||
snprintf(buf, sizeof(buf), "/sys/devices/system/cpu/cpu%i/topology/core_id", i);
|
||||
char *b = file_contents(buf);
|
||||
if (b)
|
||||
{
|
||||
cores[i].core_id = atoi(b);
|
||||
free(b);
|
||||
}
|
||||
}
|
||||
|
||||
qsort(cores, ncpu, sizeof(core_top_t), _cmp);
|
||||
|
||||
for (int i = 0; i < ncpu; i++)
|
||||
{
|
||||
ids[i] = cores[i].id;
|
||||
}
|
||||
free(cores);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ typedef struct {
|
|||
|
||||
int cpu_count;
|
||||
|
||||
int *cpu_order;
|
||||
|
||||
Eina_Bool show_cpufreq;
|
||||
// Have cpu scaling
|
||||
Eina_Bool cpu_freq;
|
||||
|
@ -154,13 +156,14 @@ _core_times_main_cb(void *data, Ecore_Thread *thread)
|
|||
for (int n = 0; n < ncpu; n++)
|
||||
{
|
||||
// Copy our core state data to mainloop
|
||||
int id = ad->cpu_order[n];
|
||||
Core *core = &(cores_out[n]);
|
||||
core->id = n;
|
||||
core->percent = cores[n]->percent;
|
||||
core->id = id;
|
||||
core->percent = cores[id]->percent;
|
||||
if (ad->cpu_freq)
|
||||
core->freq = system_cpu_n_frequency_get(n);
|
||||
core->freq = system_cpu_n_frequency_get(id);
|
||||
if (ad->cpu_temp)
|
||||
core->temp = system_cpu_n_temperature_get(n);
|
||||
core->temp = system_cpu_n_temperature_get(id);
|
||||
free(cores[n]);
|
||||
}
|
||||
ecore_thread_feedback(thread, cores_out);
|
||||
|
@ -273,7 +276,7 @@ _explain(Animate *ad, Core *cores)
|
|||
for (int i = 0; i < ad->cpu_count; i++)
|
||||
{
|
||||
Core *core = &(cores[i]);
|
||||
lb = eina_list_nth(ad->explainers, core->id);
|
||||
lb = eina_list_nth(ad->explainers, i);
|
||||
if (!ad->confused)
|
||||
evas_object_hide(lb);
|
||||
else
|
||||
|
@ -326,6 +329,7 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
|
|||
ecore_thread_wait(ui->cpu.thread, 0.5);
|
||||
eina_list_free(ad->explainers);
|
||||
ad->explainers = NULL;
|
||||
free(ad->cpu_order);
|
||||
free(ad);
|
||||
ui->cpu.win = NULL;
|
||||
}
|
||||
|
@ -399,6 +403,11 @@ _graph(Ui *ui, Evas_Object *parent)
|
|||
if ((system_cpu_n_temperature_get(0)) != -1)
|
||||
ad->cpu_temp = EINA_TRUE;
|
||||
|
||||
ad->cpu_order = malloc((ad->cpu_count) * sizeof(int));
|
||||
for (i = 0; i < ad->cpu_count; i++)
|
||||
ad->cpu_order[i] = i;
|
||||
system_cpu_topology_get(ad->cpu_order, ad->cpu_count);
|
||||
|
||||
// init colormaps from a small # of points
|
||||
_color_init(cpu_colormap_in, COLOR_CPU_NUM, cpu_colormap);
|
||||
_color_init(freq_colormap_in, COLOR_FREQ_NUM, freq_colormap);
|
||||
|
@ -458,7 +467,7 @@ _graph(Ui *ui, Evas_Object *parent)
|
|||
elm_table_pack(tbl, rec, 2, i, 1, 1);
|
||||
|
||||
lb = elm_label_add(parent);
|
||||
snprintf(buf, sizeof(buf), "<b><color=#fff>%i</></>", i);
|
||||
snprintf(buf, sizeof(buf), "<b><color=#fff>%i</></>", ad->cpu_order[i]);
|
||||
elm_object_text_set(lb, buf);
|
||||
evas_object_size_hint_align_set(lb, 1.0, 0.5);
|
||||
evas_object_size_hint_weight_set(lb, 0.0, EXPAND);
|
||||
|
|
Loading…
Reference in New Issue