evlog tool - read cpu usage and cpufreq info 7 display now

This commit is contained in:
Carsten Haitzler 2016-11-10 01:01:38 +09:00
parent c4ad4ece02
commit de55d0048a
3 changed files with 481 additions and 73 deletions

View File

@ -1,5 +1,9 @@
#!/bin/sh
gcc evlog.c -o evlog `pkg-config --cflags --libs elementary` -g
#!/bin/sh -e
gcc \
evlog.c \
-o evlog \
-O2 -march=native -g \
`pkg-config --cflags --libs elementary`
edje_cc evlog.edc -id ./img
### minimal docs!

522
evlog.c
View File

@ -13,31 +13,55 @@ Evas_Object *zoom_slider;
typedef struct _Evlog Evlog;
typedef struct _Evlog_Thread Evlog_Thread;
typedef struct _Evlog_Event Evlog_Event;
typedef struct _Evlog_Cpu_Use Evlog_Cpu_Use;
typedef struct _Evlog_Cpu_Freq Evlog_Cpu_Freq;
struct _Evlog
{
FILE *file;
double first_timestamp;
double last_timestamp;
int state_num;
int thread_num;
Evlog_Event *states;
Evlog_Thread *threads;
FILE *file;
double first_timestamp;
double last_timestamp;
int state_uniq;
int state_num;
int cpucores;
int cpumhzmax;
int thread_num;
int cpufreq_num;
Evlog_Event *states;
Evlog_Thread *threads;
Evlog_Cpu_Freq *cpufreqs;
char **state_uniq_str;
int cpumhzlast[64];
};
struct _Evlog_Event
{
const char *event;
// const char *detail;
const char *detail;
double timestamp;
double latency;
};
struct _Evlog_Cpu_Use
{
int usage;
double timestamp;
};
struct _Evlog_Cpu_Freq
{
int core;
int mhz;
double timestamp;
};
struct _Evlog_Thread
{
unsigned long long id;
int event_num;
int cpuused_num;
Evlog_Event *events;
Evlog_Cpu_Use *cpuused;
};
typedef struct
@ -48,6 +72,7 @@ typedef struct
Evas_Object *table;
struct {
Evas_Object *state;
Evas_Object *cpufreq;
Evas_Object **thread;
Evas_Object *over;
} grid;
@ -56,7 +81,7 @@ typedef struct
Ecore_Job *job;
Ecore_Thread *thread;
double t0, t1, tmin;
Eina_Bool redo : 1;
volatile Eina_Bool redo;
Eina_List *remobjs;
} update;
} Inf;
@ -65,11 +90,13 @@ typedef struct
{
void *src;
char *event;
char *detail;
Evas_Object *obj;
double t0, t1;
int n;
int n, n2;
int slot;
Eina_Bool nuke : 1;
Eina_Bool cpu_use : 1;
} Event;
#define ROUND_AMOUNT 1024
@ -95,8 +122,19 @@ static void _fill_begin(Inf *inf);
static void
evlog_state_event_register(Evlog *evlog, Evlog_Event *ev)
{
int n0, n;
int n0, n, j;
for (j = 0; j < evlog->state_uniq; j++)
{
if (!strcmp(evlog->state_uniq_str[j], ev->event + 1)) break;
}
if (j == evlog->state_uniq)
{
evlog->state_uniq++;
evlog->state_uniq_str = realloc(evlog->state_uniq_str,
evlog->state_uniq * sizeof(char *));
evlog->state_uniq_str[evlog->state_uniq - 1] = strdup(ev->event + 1);
}
n0 = evlog->state_num;
evlog->state_num++;
n = evlog->state_num;
@ -110,6 +148,7 @@ evlog_state_event_register(Evlog *evlog, Evlog_Event *ev)
if (!tmp)
{
eina_stringshare_del(ev->event);
eina_stringshare_del(ev->detail);
return;
}
evlog->states = tmp;
@ -135,6 +174,7 @@ evlog_thread_event_register(Evlog_Thread *th, Evlog_Event *ev)
if (!tmp)
{
eina_stringshare_del(ev->event);
eina_stringshare_del(ev->detail);
return;
}
th->events = tmp;
@ -142,6 +182,85 @@ evlog_thread_event_register(Evlog_Thread *th, Evlog_Event *ev)
th->events[th->event_num - 1] = *ev;
}
static void
evlog_thread_cpu_freq(Evlog *evlog, double timestamp, int core, int mhz)
{
int n0, n;
n0 = evlog->cpufreq_num;
evlog->cpufreq_num++;
n = evlog->cpufreq_num;
n0 = ROUND(n0);
n = ROUND(n);
if (n != n0)
{
Evlog_Cpu_Freq *tmp;
tmp = realloc(evlog->cpufreqs, n * sizeof(Evlog_Cpu_Freq));
if (!tmp) return;
evlog->cpufreqs = tmp;
}
evlog->cpufreqs[evlog->cpufreq_num - 1].core = core;
evlog->cpufreqs[evlog->cpufreq_num - 1].mhz = mhz;
evlog->cpufreqs[evlog->cpufreq_num - 1].timestamp = timestamp;
if (evlog->cpucores <= core) evlog->cpucores = core + 1;
if (mhz > evlog->cpumhzmax) evlog->cpumhzmax = mhz;
evlog->cpumhzlast[core] = mhz;
}
static void
evlog_thread_cpu_use(Evlog_Thread *th, double timestamp, int cpu)
{
int n0, n;
n0 = th->cpuused_num;
th->cpuused_num++;
n = th->cpuused_num;
n0 = ROUND(n0);
n = ROUND(n);
if (n != n0)
{
Evlog_Cpu_Use *tmp;
tmp = realloc(th->cpuused, n * sizeof(Evlog_Cpu_Use));
if (!tmp) return;
th->cpuused = tmp;
}
th->cpuused[th->cpuused_num - 1].usage = cpu;
th->cpuused[th->cpuused_num - 1].timestamp = timestamp;
}
static Eina_Bool
evlog_thread_push(Evlog *evlog, int slot, unsigned long long thread)
{
Evlog_Thread *tmp;
if (slot < evlog->thread_num) return EINA_TRUE;
evlog->thread_num = slot + 1;
tmp = realloc(evlog->threads, evlog->thread_num * sizeof(Evlog_Thread));
if (!tmp) return EINA_FALSE;
evlog->threads = tmp;
evlog->threads[slot].id = thread;
evlog->threads[slot].event_num = 0;
evlog->threads[slot].events = NULL;
evlog->threads[slot].cpuused_num = 0;
evlog->threads[slot].cpuused = NULL;
return EINA_TRUE;
}
static int
evlog_thread_slot_find(Evlog *evlog, unsigned long long thread)
{
int i;
for (i = 0; i < evlog->thread_num; i++)
{
if (evlog->threads[i].id == thread) return i;
}
return i;
}
static void
evlog_event_register(Evlog *evlog, unsigned long long thread, Evlog_Event *ev)
{
@ -151,28 +270,36 @@ evlog_event_register(Evlog *evlog, unsigned long long thread, Evlog_Event *ev)
{
evlog_state_event_register(evlog, ev);
}
else if (ev->event[0] == '*')
{
if ((!strncmp(ev->event, "*CPUFREQ ", 9)) && (ev->detail))
{
int cpu = atoi(ev->event + 9);
int freq = atoi(ev->detail);
evlog_thread_cpu_freq(evlog, ev->timestamp, cpu, freq);
}
else if ((!strncmp(ev->event, "*CPUUSED ", 9)) && (ev->detail))
{
unsigned long long thcpu = atoll(ev->event + 9);
int cpu = atoi(ev->detail);
i = evlog_thread_slot_find(evlog, thcpu);
if (!evlog_thread_push(evlog, i, thcpu)) return;
for (int j = 0; j < i; j++) printf(" ");
evlog_thread_cpu_use(&(evlog->threads[i]), ev->timestamp, cpu);
}
eina_stringshare_del(ev->event);
eina_stringshare_del(ev->detail);
}
else
{
for (i = 0; i < evlog->thread_num; i++)
i = evlog_thread_slot_find(evlog, thread);
if (!evlog_thread_push(evlog, i, thread))
{
if (evlog->threads[i].id == thread) break;
}
if (i >= evlog->thread_num)
{
Evlog_Thread *tmp;
evlog->thread_num++;
tmp = realloc(evlog->threads,
evlog->thread_num * sizeof(Evlog_Thread));
if (!tmp)
{
eina_stringshare_del(ev->event);
return;
}
evlog->threads = tmp;
evlog->threads[i].id = thread;
evlog->threads[i].event_num = 0;
evlog->threads[i].events = NULL;
eina_stringshare_del(ev->event);
eina_stringshare_del(ev->detail);
return;
}
evlog_thread_event_register(&(evlog->threads[i]), ev);
}
@ -198,6 +325,10 @@ evlog_event_read(Evlog *evlog, void *ptr, void *end)
{
Evlog_Event ev;
ev.event = eina_stringshare_add(eventstr);
if (detailstr)
ev.detail = eina_stringshare_add(detailstr);
else
ev.detail = NULL;
ev.timestamp = (item.srctim == 0.0) ? item.tim : item.srctim;
ev.latency = (item.srctim != 0.0) ? item.tim - item.srctim : 0.0;
if (evlog->first_timestamp == 0.0)
@ -215,6 +346,7 @@ evlog_event_read(Evlog *evlog, void *ptr, void *end)
static Eina_Bool
evlog_block_read(Evlog *evlog)
{
int i;
unsigned int header[3];
Eina_Bool bigendian = EINA_FALSE;
@ -241,6 +373,11 @@ evlog_block_read(Evlog *evlog)
while ((ptr = evlog_event_read(evlog, ptr, end)));
free(buf);
}
for (i = 0; i < evlog->cpucores; i++)
{
evlog_thread_cpu_freq(evlog, evlog->last_timestamp,
i, evlog->cpumhzlast[i]);
}
}
else
{
@ -307,7 +444,7 @@ _create_log_states(Evas_Object *win, Evlog *evlog, Evas_Object *zoom)
{
Evas_Object *o, *oo;
double len = evlog->last_timestamp - evlog->first_timestamp;
int i;
int i, j;
int h = 0;
Eina_List *events = NULL, *l;
Event *ev;
@ -326,9 +463,17 @@ _create_log_states(Evas_Object *win, Evlog *evlog, Evas_Object *zoom)
{
ev->src = e;
ev->event = strdup(e->event + 1);
if (e->detail) ev->detail = strdup(e->detail);
ev->t0 = t;
events = eina_list_append(events, ev);
ev->n = eina_list_count(events) - 1;
for (j = 0; j < evlog->state_uniq; j++)
{
if (!strcmp(evlog->state_uniq_str[j], ev->event))
{
ev->n = j;
break;
}
}
if ((ev->n + 1) > h) h = ev->n + 1;
}
}
@ -340,6 +485,7 @@ _create_log_states(Evas_Object *win, Evlog *evlog, Evas_Object *zoom)
{
ev->t1 = t;
free(ev->event);
free(ev->detail);
free(ev);
events = eina_list_remove_list(events, l);
break;
@ -352,6 +498,7 @@ _create_log_states(Evas_Object *win, Evlog *evlog, Evas_Object *zoom)
{
ev->t1 = t;
free(ev->event);
free(ev->detail);
free(ev);
}
@ -379,6 +526,7 @@ _add_log_state(Inf *inf, Event *ev)
if (ev2->src == ev->src)
{
free(ev->event);
free(ev->detail);
free(ev);
return;
}
@ -386,14 +534,52 @@ _add_log_state(Inf *inf, Event *ev)
inf->objs = eina_list_append(inf->objs, ev);
}
static void
_add_log_event(Inf *inf, Event *ev)
{
Eina_List *l;
Event *ev2;
EINA_LIST_FOREACH(inf->objs, l, ev2)
{
if (ev2->src == ev->src)
{
free(ev->event);
free(ev->detail);
free(ev);
return;
}
}
inf->objs = eina_list_append(inf->objs, ev);
}
static Evas_Object *
_create_cpufreq_states(Evas_Object *win, Evlog *evlog)
{
Evas_Object *o, *oo;
double len = evlog->last_timestamp - evlog->first_timestamp;
o = elm_grid_add(win);
elm_grid_size_set(o, len * RES, evlog->cpucores);
evas_object_size_hint_min_set(o, 1, evlog->cpucores * 10);
oo = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(oo, 16, 16, 16, 255);
elm_grid_pack(o, oo, 0, 0, len * RES, evlog->cpucores * 4);
evas_object_show(oo);
return o;
}
static void
_fill_log_states(Inf *inf, Evlog *evlog, double t0, double t1, double tmin)
{
int i;
int i, j;
Eina_List *events = NULL, *l;
Event *ev;
char buf[256];
Evlog_Event *e;
double t;
double *ct;
for (i = 0; i < evlog->state_num; i++)
{
@ -406,9 +592,17 @@ _fill_log_states(Inf *inf, Evlog *evlog, double t0, double t1, double tmin)
{
ev->src = e;
ev->event = strdup(e->event + 1);
if (e->detail) ev->detail = strdup(e->detail);
ev->t0 = t;
events = eina_list_append(events, ev);
ev->n = eina_list_count(events) - 1;
for (j = 0; j < evlog->state_uniq; j++)
{
if (!strcmp(evlog->state_uniq_str[j], ev->event))
{
ev->n = j;
break;
}
}
ev->slot = 0;
}
}
@ -424,6 +618,7 @@ _fill_log_states(Inf *inf, Evlog *evlog, double t0, double t1, double tmin)
else
{
free(ev->event);
free(ev->detail);
free(ev);
}
events = eina_list_remove_list(events, l);
@ -432,6 +627,33 @@ _fill_log_states(Inf *inf, Evlog *evlog, double t0, double t1, double tmin)
}
}
}
ct = calloc(evlog->cpucores, sizeof(double));
for (i = 0; i < evlog->cpufreq_num; i++)
{
Evlog_Cpu_Freq *f = &(evlog->cpufreqs[i]);
double tt = f->timestamp - evlog->first_timestamp;
if (_can_see(t0, t1, tmin, ct[f->core], tt))
{
ev = calloc(1, sizeof(Event));
if (ev)
{
ev->src = f;
ev->event = strdup("*CPUFREQ");
snprintf(buf, sizeof(buf), "%iMHz", f->mhz);
ev->detail = strdup(buf);
ev->n = f->core;
ev->n2 = f->mhz;
ev->t0 = ct[f->core];
ev->t1 = tt;
ev->slot = -2;
_add_log_event(inf, ev);
}
}
ct[f->core] = tt;
}
free(ct);
t = evlog->last_timestamp - evlog->first_timestamp;
EINA_LIST_FREE(events, ev)
{
@ -441,6 +663,7 @@ _fill_log_states(Inf *inf, Evlog *evlog, double t0, double t1, double tmin)
else
{
free(ev->event);
free(ev->detail);
free(ev);
}
}
@ -479,6 +702,7 @@ _create_log_thread(Evas_Object *win, Evlog *evlog, Evlog_Thread *th, int slot, E
ev->src = e;
stack = eina_list_append(stack, ev);
ev->event = strdup(e->event + 1);
if (e->detail) ev->detail = strdup(e->detail);
ev->t0 = t;
ev->n = eina_list_count(stack) - 1;
if ((ev->n + 1) > h) h = ev->n + 1;
@ -501,6 +725,9 @@ _create_log_thread(Evas_Object *win, Evlog *evlog, Evlog_Thread *th, int slot, E
}
else if (e->event[0] == '*')
{
// XXX: handle:
// 'CPUFREQ [X]' (CPU core) | [N] (Mhz)
// 'CPUUSED [X]' (Thread ID) | [N] (percent CPU used)
}
}
t = evlog->last_timestamp - evlog->first_timestamp;
@ -508,38 +735,21 @@ _create_log_thread(Evas_Object *win, Evlog *evlog, Evlog_Thread *th, int slot, E
{
ev->t1 = t;
free(ev->event);
free(ev->detail);
free(ev);
}
if (h < 1) h = 1;
elm_grid_size_set(o, len * RES, h);
evas_object_size_hint_min_set(o, 1, h * 20);
elm_grid_size_set(o, len * RES, (h * 2) + 1);
evas_object_size_hint_min_set(o, 1, (h * 20) + 10);
oo = evas_object_rectangle_add(evas_object_evas_get(win));
c = 32 + ((slot % 2) * 16);
evas_object_color_set(oo, c, c, c, 255);
elm_grid_pack(o, oo, 0, 0, len * RES, h);
elm_grid_pack(o, oo, 0, 0, len * RES, (h * 2) + 1);
evas_object_show(oo);
return o;
}
static void
_add_log_event(Inf *inf, Event *ev)
{
Eina_List *l;
Event *ev2;
EINA_LIST_FOREACH(inf->objs, l, ev2)
{
if (ev2->src == ev->src)
{
free(ev->event);
free(ev);
return;
}
}
inf->objs = eina_list_append(inf->objs, ev);
}
static void
_fill_log_thread(Inf *inf, Evlog *evlog, Evlog_Thread *th, int slot, double t0, double t1, double tmin)
{
@ -549,6 +759,8 @@ _fill_log_thread(Inf *inf, Evlog *evlog, Evlog_Thread *th, int slot, double t0,
int h = 0;
Evlog_Event *e;
double t;
char buf[256];
void *psrc;
for (i = 0; i < th->event_num; i++)
{
@ -562,6 +774,7 @@ _fill_log_thread(Inf *inf, Evlog *evlog, Evlog_Thread *th, int slot, double t0,
ev->src = e;
stack = eina_list_append(stack, ev);
ev->event = strdup(e->event + 1);
if (e->detail) ev->detail = strdup(e->detail);
ev->t0 = t;
ev->n = eina_list_count(stack) - 1;
ev->slot = slot;
@ -580,6 +793,7 @@ _fill_log_thread(Inf *inf, Evlog *evlog, Evlog_Thread *th, int slot, double t0,
else
{
free(ev->event);
free(ev->detail);
free(ev);
}
stack = eina_list_remove_list(stack, l);
@ -592,6 +806,7 @@ _fill_log_thread(Inf *inf, Evlog *evlog, Evlog_Thread *th, int slot, double t0,
{
ev->src = e;
ev->event = strdup(e->event + 1);
if (e->detail) ev->detail = strdup(e->detail);
ev->t0 = t;
ev->t1 = -1.0;
ev->n = 0;
@ -601,13 +816,17 @@ _fill_log_thread(Inf *inf, Evlog *evlog, Evlog_Thread *th, int slot, double t0,
else
{
free(ev->event);
free(ev->detail);
free(ev);
}
}
}
else if (e->event[0] == '*')
{
}
// else if (e->event[0] == '*')
// {
// XXX: handle:
// 'CPUFREQ [X]' (CPU core) | [N] (Mhz)
// 'CPUUSED [X]' (Thread ID) | [N] (percent CPU used)
// }
}
t = evlog->last_timestamp - evlog->first_timestamp;
EINA_LIST_FREE(stack, ev)
@ -618,9 +837,34 @@ _fill_log_thread(Inf *inf, Evlog *evlog, Evlog_Thread *th, int slot, double t0,
else
{
free(ev->event);
free(ev->detail);
free(ev);
}
}
t = 0.0;
for (i = 0; i < th->cpuused_num; i++)
{
double tt = th->cpuused[i].timestamp - evlog->first_timestamp;
if (_can_see(t0, t1, tmin, t, tt))
{
ev = calloc(1, sizeof(Event));
if (ev)
{
ev->src = &(th->cpuused[i]);
ev->event = strdup("*CPUUSED");
snprintf(buf, sizeof(buf), "%i%%", th->cpuused[i].usage);
ev->detail = strdup(buf);
ev->t0 = t;
ev->t1 = tt;
ev->n = th->cpuused[i].usage;
ev->slot = slot;
ev->cpu_use = 1;
_add_log_event(inf, ev);
}
}
t = tt;
}
}
static void
@ -658,6 +902,20 @@ _fill_log_table(Evas_Object *win, Evas_Object *tb, Evlog *evlog, Evas_Object *zo
char buf[256];
int i, y = 0;
o = elm_label_add(win);
elm_object_text_set(o, "<b>CPU FREQ</b>");
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
elm_table_pack(tb, o, 0, y, 1, 1);
evas_object_show(o);
o = _create_cpufreq_states(win, evlog);
inf->grid.cpufreq = o;
evas_object_size_hint_weight_set(o, 0.0, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
elm_table_pack(tb, o, 2, y++, 1, 1);
evas_object_show(o);
o = elm_label_add(win);
elm_object_text_set(o, "<b>STATES</b>");
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
@ -750,7 +1008,8 @@ static Evas_Object *
_add_log_state_object(Evas_Object *win, Evas_Object *grid, Event *ev)
{
Evas_Object *o, *oe;
int col[4] = {255, 255, 255, 255}, i;
unsigned char col[4] = {255, 255, 255, 255};
int i;
char *s;
char buf[512];
@ -763,13 +1022,30 @@ _add_log_state_object(Evas_Object *win, Evas_Object *grid, Event *ev)
col[i % 3] ^= *s;
i++;
}
if (ev->detail)
{
for (s = ev->detail; *s; s++)
{
col[i % 3] ^= ((*s << 3) | (i << 1));
i++;
}
}
edje_object_color_class_set(oe, "state",
col[0] / 2, col[1] / 2, col[2] / 2, col[3],
255, 255, 255, 255,
255, 255, 255, 255);
edje_object_part_text_set(oe, "text", ev->event);
if (ev->detail)
{
snprintf(buf, sizeof(buf), "%s (%s)", ev->event, ev->detail);
edje_object_part_text_set(oe, "text", buf);
}
else
edje_object_part_text_set(oe, "text", ev->event);
elm_grid_pack(grid, o, ev->t0 * RES, ev->n, (ev->t1 - ev->t0) * RES, 1);
snprintf(buf, sizeof(buf), "%s - %1.9fms ~ %1.9fms", ev->event, ev->t0 * 1000.0, (ev->t1 - ev->t0) * 1000.0);
if (ev->detail)
snprintf(buf, sizeof(buf), "%s (%s) - %1.5fms [%1.5fms]", ev->event, ev->detail, ev->t0 * 1000.0, (ev->t1 - ev->t0) * 1000.0);
else
snprintf(buf, sizeof(buf), "%s - %1.5fms [%1.5fms]", ev->event, ev->t0 * 1000.0, (ev->t1 - ev->t0) * 1000.0);
elm_object_tooltip_text_set(o, buf);
evas_object_show(o);
return o;
@ -796,9 +1072,56 @@ _add_log_event_object(Evas_Object *win, Evas_Object *grid, Event *ev)
col[0] / 2, col[1] / 2, col[2] / 2, col[3],
255, 255, 255, 255,
255, 255, 255, 255);
edje_object_part_text_set(oe, "text", ev->event);
elm_grid_pack(grid, o, ev->t0 * RES, ev->n, (ev->t1 - ev->t0) * RES, 1);
snprintf(buf, sizeof(buf), "%s - %1.9fms ~ %1.9fms", ev->event, ev->t0 * 1000.0, (ev->t1 - ev->t0) * 1000.0);
if (ev->detail)
{
snprintf(buf, sizeof(buf), "%s (%s)", ev->event, ev->detail);
edje_object_part_text_set(oe, "text", buf);
}
else
edje_object_part_text_set(oe, "text", ev->event);
elm_grid_pack(grid, o, ev->t0 * RES, 1 + (ev->n * 2), (ev->t1 - ev->t0) * RES, 2);
if (ev->detail)
snprintf(buf, sizeof(buf), "%s (%s) - %1.5fms [%1.5fms]", ev->event, ev->detail, ev->t0 * 1000.0, (ev->t1 - ev->t0) * 1000.0);
else
snprintf(buf, sizeof(buf), "%s - %1.5fms [%1.5fms]", ev->event, ev->t0 * 1000.0, (ev->t1 - ev->t0) * 1000.0);
elm_object_tooltip_text_set(o, buf);
evas_object_show(o);
return o;
}
static Evas_Object *
_add_log_cpuused_object(Evas_Object *win, Evas_Object *grid, Event *ev)
{
Evas_Object *o, *oe;
int col[4] = {0, 0, 0, 255}, i;
char buf[512];
o = elm_layout_add(win);
oe = elm_layout_edje_get(o);
elm_layout_file_set(o, "./evlog.edj", "cpuused");
i = 0;
if (ev->n <= 33)
{
col[0] = (ev->n * 255) / 33;
}
else if (ev->n <= 67)
{
col[0] = 255;
col[1] = ((ev->n - 33) * 255) / 24;
}
else
{
col[0] = 255;
col[1] = 255;
col[2] = ((ev->n - 67) * 255) / 33;
}
edje_object_color_class_set(oe, "range",
col[0], col[1], col[2], col[3],
255, 255, 255, 255,
255, 255, 255, 255);
elm_grid_pack(grid, o, ev->t0 * RES, 0, (ev->t1 - ev->t0) * RES, 1);
if (ev->detail)
snprintf(buf, sizeof(buf), "%i%% - %1.5fms [%1.5fms]", ev->n, ev->t0 * 1000.0, (ev->t1 - ev->t0) * 1000.0);
elm_object_tooltip_text_set(o, buf);
evas_object_show(o);
return o;
@ -814,7 +1137,47 @@ _add_log_frame_object(Evas_Object *win, Evas_Object *grid, Event *ev)
oe = elm_layout_edje_get(o);
elm_layout_file_set(o, "./evlog.edj", "frame");
elm_grid_pack(grid, o, ev->t0 * RES, ev->n, (ev->t1 - ev->t0) * RES, 1);
snprintf(buf, sizeof(buf), "%s - %1.9fms", ev->event, ev->t0 * 1000.0);
snprintf(buf, sizeof(buf), "%s - %1.5fms", ev->event, ev->t0 * 1000.0);
elm_object_tooltip_text_set(o, buf);
evas_object_show(o);
return o;
}
static Evas_Object *
_add_log_cpufreq_object(Evas_Object *win, Evas_Object *grid, Event *ev, int mhzmax)
{
Evas_Object *o, *oe;
int col[4] = {0, 0, 0, 255}, i, n;
char buf[512];
o = elm_layout_add(win);
oe = elm_layout_edje_get(o);
elm_layout_file_set(o, "./evlog.edj", "cpufreq");
i = 0;
n = (ev->n2 * 100) / mhzmax;
if (n <= 33)
{
col[0] = (n * 255) / 33;
}
else if (n <= 67)
{
col[0] = 255;
col[1] = ((n - 33) * 255) / 24;
}
else
{
col[0] = 255;
col[1] = 255;
col[2] = ((n - 67) * 255) / 33;
}
edje_object_color_class_set(oe, "range",
col[0], col[1], col[2], col[3],
255, 255, 255, 255,
255, 255, 255, 255);
elm_grid_pack(grid, o, ev->t0 * RES, ev->n, (ev->t1 - ev->t0) * RES, 1);
if (ev->detail)
snprintf(buf, sizeof(buf), "%iMHz - %1.5fms [%1.5fms]", ev->n2, ev->t0 * 1000.0, (ev->t1 - ev->t0) * 1000.0);
elm_object_tooltip_text_set(o, buf);
evas_object_show(o);
return o;
@ -842,9 +1205,14 @@ _cb_fill_end(void *data, Ecore_Thread *thread)
}
else if (ev->slot > 0) // thread
{
o = _add_log_event_object(inf->win,
inf->grid.thread[ev->slot - 1],
ev);
if (!strcmp(ev->event, "*CPUUSED"))
o = _add_log_cpuused_object(inf->win,
inf->grid.thread[ev->slot - 1],
ev);
else
o = _add_log_event_object(inf->win,
inf->grid.thread[ev->slot - 1],
ev);
ev->obj = o;
}
else if (ev->slot == -1) // frames
@ -857,6 +1225,17 @@ _cb_fill_end(void *data, Ecore_Thread *thread)
ev->obj = o;
}
}
else if (ev->slot == -2) // cpufreq
{
if (!strcmp(ev->event, "*CPUFREQ"))
{
o = _add_log_cpufreq_object(inf->win,
inf->grid.cpufreq,
ev,
inf->evlog->cpumhzmax);
ev->obj = o;
}
}
}
}
EINA_LIST_FREE(inf->update.remobjs, ev)
@ -864,6 +1243,7 @@ _cb_fill_end(void *data, Ecore_Thread *thread)
inf->objs = eina_list_remove(inf->objs, ev);
if (ev->obj) evas_object_del(ev->obj);
free(ev->event);
free(ev->detail);
free(ev);
}
if (inf->update.redo)
@ -913,7 +1293,7 @@ _fill_begin(Inf *inf)
t0 = inf->evlog->first_timestamp;
t1 = inf->evlog->last_timestamp;
inf->update.tmin = (1.0 * (double)gw) / ((double)w * RES);
inf->update.tmin = (3.0 * (double)gw) / ((double)w * RES);
wx -= 100;
ww += 200;
@ -1037,7 +1417,7 @@ elm_main(int argc, char **argv)
evas_object_data_set(o, "inf", inf);
elm_slider_min_max_set(o, 1.0, 1000.0);
elm_slider_step_set(o, 0.1);
elm_slider_value_set(o, 20.0);
elm_slider_value_set(o, 50.0);
elm_object_text_set(o, "Zoom");
elm_slider_unit_format_set(o, "%1.1f");
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
@ -1051,7 +1431,7 @@ elm_main(int argc, char **argv)
elm_box_pack_end(box, o);
evas_object_show(o);
evas_object_resize(win, 620, 400);
evas_object_resize(win, 1200, 400);
evas_object_show(win);
elm_run();

View File

@ -29,6 +29,30 @@ collections {
}
}
group { name: "cpufreq";
parts {
part { name: "bg"; type: RECT;
description { state: "default" 0.0;
// rel1.offset: 1 1;
// rel2.offset: -2 -2;
color_class: "range";
}
}
}
}
group { name: "cpuused";
parts {
part { name: "bg"; type: RECT;
description { state: "default" 0.0;
// rel1.offset: 1 1;
// rel2.offset: -2 -2;
color_class: "range";
}
}
}
}
images.image: "diagonal_stripes.png" COMP;
group { name: "state";