cpu...leeenooks
This commit is contained in:
parent
b139724e26
commit
af63cd9ce6
|
@ -100,6 +100,12 @@ system_cpu_usage_delayed_get(int *ncpu, int usecs);
|
||||||
int
|
int
|
||||||
system_cpu_frequency_get(void);
|
system_cpu_frequency_get(void);
|
||||||
|
|
||||||
|
int
|
||||||
|
system_cpu_n_frequency_get(int n);
|
||||||
|
|
||||||
|
int
|
||||||
|
system_cpu_frequency_min_max_get(int *min, int *max);
|
||||||
|
|
||||||
void
|
void
|
||||||
system_memory_usage_get(meminfo_t *memory);
|
system_memory_usage_get(meminfo_t *memory);
|
||||||
|
|
||||||
|
|
|
@ -279,6 +279,75 @@ system_cpu_usage_get(int *ncpu)
|
||||||
return system_cpu_usage_delayed_get(ncpu, 1000000);
|
return system_cpu_usage_delayed_get(ncpu, 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
system_cpu_n_frequency_get(int n)
|
||||||
|
{
|
||||||
|
int freq = -1;
|
||||||
|
FILE *f;
|
||||||
|
char buf[4096];
|
||||||
|
int tmp;
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", n);
|
||||||
|
f = fopen(buf, "r");
|
||||||
|
if (f)
|
||||||
|
{
|
||||||
|
if (fgets(buf, sizeof(buf), f))
|
||||||
|
{
|
||||||
|
tmp = strtol(buf, NULL, 10);
|
||||||
|
if (!((tmp == LONG_MIN || tmp == LONG_MAX) && errno == ERANGE))
|
||||||
|
freq = tmp;
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
if (freq != -1) return freq;
|
||||||
|
}
|
||||||
|
|
||||||
|
return freq;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
system_cpu_frequency_min_max_get(int *min, int *max)
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
int freq_min = 0x7fffffff, freq_max = 0;
|
||||||
|
|
||||||
|
s = file_contents("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq");
|
||||||
|
if (s)
|
||||||
|
{
|
||||||
|
freq_min = atoi(s);
|
||||||
|
free(s);
|
||||||
|
s = file_contents("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq");
|
||||||
|
if (s)
|
||||||
|
{
|
||||||
|
freq_max = atoi(s);
|
||||||
|
free(s);
|
||||||
|
*min = freq_min;
|
||||||
|
*max = freq_max;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s = file_contents("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies");
|
||||||
|
if (!s) return -1;
|
||||||
|
|
||||||
|
char *t = strtok(s, " ");
|
||||||
|
while (t)
|
||||||
|
{
|
||||||
|
int freq = atoi(t);
|
||||||
|
if (freq > freq_max) freq_max = freq;
|
||||||
|
if (freq < freq_min) freq_min = freq;
|
||||||
|
t = strtok(NULL, " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
free(s);
|
||||||
|
|
||||||
|
if (freq_min == 0x7fffffff || freq_max == 0) return -1;
|
||||||
|
|
||||||
|
*min = freq_min;
|
||||||
|
*max = freq_max;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
system_cpu_frequency_get(void)
|
system_cpu_frequency_get(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,8 @@ typedef struct {
|
||||||
Animate_Data *anim_data;
|
Animate_Data *anim_data;
|
||||||
double *value;
|
double *value;
|
||||||
Evas_Object *pb;
|
Evas_Object *pb;
|
||||||
|
|
||||||
|
int freq;
|
||||||
} Progress;
|
} Progress;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -161,12 +163,19 @@ _core_times_cb(void *data, Ecore_Thread *thread)
|
||||||
|
|
||||||
ui = data;
|
ui = data;
|
||||||
|
|
||||||
|
int min, max;
|
||||||
|
|
||||||
|
if (!system_cpu_frequency_min_max_get(&min, &max))
|
||||||
|
{
|
||||||
|
printf("min %d and max %d\n", min, max);
|
||||||
|
}
|
||||||
for (int i = 0; !ecore_thread_check(thread); i = 0)
|
for (int i = 0; !ecore_thread_check(thread); i = 0)
|
||||||
{
|
{
|
||||||
cores = system_cpu_usage_get(&ncpu);
|
cores = system_cpu_usage_get(&ncpu);
|
||||||
EINA_LIST_FOREACH(ui->cpu_list, l, progress)
|
EINA_LIST_FOREACH(ui->cpu_list, l, progress)
|
||||||
{
|
{
|
||||||
*progress->value = cores[i]->percent;
|
*progress->value = cores[i]->percent;
|
||||||
|
progress->freq = system_cpu_n_frequency_get(progress->anim_data->cpu_id);
|
||||||
ecore_thread_main_loop_begin();
|
ecore_thread_main_loop_begin();
|
||||||
elm_progressbar_value_set(progress->pb, cores[i]->percent / 100);
|
elm_progressbar_value_set(progress->pb, cores[i]->percent / 100);
|
||||||
ecore_thread_main_loop_end();
|
ecore_thread_main_loop_end();
|
||||||
|
|
|
@ -585,7 +585,7 @@ evisum_ui_animate(void *data)
|
||||||
evas_object_image_fill_set(bg, ww / 3, 0, iw, wh);
|
evas_object_image_fill_set(bg, ww / 3, 0, iw, wh);
|
||||||
evas_object_resize(bg, iw, wh);
|
evas_object_resize(bg, iw, wh);
|
||||||
evas_object_move(bg, 0, 0);
|
evas_object_move(bg, 0, 0);
|
||||||
evas_object_color_set(bg, 255, 255, 255, 128);
|
evas_object_color_set(bg, 64, 64, 64, 64);
|
||||||
evas_object_pass_events_set(bg, 1);
|
evas_object_pass_events_set(bg, 1);
|
||||||
evas_object_show(bg);
|
evas_object_show(bg);
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ evisum_ui_animate(void *data)
|
||||||
evas_object_image_fill_set(im, ww / 2, 0, iw, wh);
|
evas_object_image_fill_set(im, ww / 2, 0, iw, wh);
|
||||||
evas_object_resize(im, iw, wh);
|
evas_object_resize(im, iw, wh);
|
||||||
evas_object_move(im, 0, 0);
|
evas_object_move(im, 0, 0);
|
||||||
evas_object_color_set(im, 255, 255, 255, 128);
|
evas_object_color_set(im, 192, 192, 192, 192);
|
||||||
evas_object_pass_events_set(im, 1);
|
evas_object_pass_events_set(im, 1);
|
||||||
evas_object_show(im);
|
evas_object_show(im);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue