linux: Run time.
This commit is contained in:
parent
04b4fd7fcf
commit
1938250af4
|
@ -1,6 +1,6 @@
|
||||||
##### Project
|
##### Project
|
||||||
project('evisum', 'c',
|
project('evisum', 'c',
|
||||||
version : '0.5.10',
|
version : '0.5.11',
|
||||||
meson_version : '>= 0.40.0')
|
meson_version : '>= 0.40.0')
|
||||||
|
|
||||||
efl_version = '>= 1.22.0'
|
efl_version = '>= 1.22.0'
|
||||||
|
|
|
@ -284,7 +284,7 @@ _boot_time(void)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int pid, ppid, utime, stime, cutime, cstime;
|
int pid, ppid, utime, stime, cutime, cstime;
|
||||||
int psr, pri, nice, numthreads;
|
int psr, pri, nice, numthreads;
|
||||||
long long int start_time;
|
long long int start_time, run_time;
|
||||||
char state;
|
char state;
|
||||||
unsigned int mem_rss, flags;
|
unsigned int mem_rss, flags;
|
||||||
unsigned long mem_virt;
|
unsigned long mem_virt;
|
||||||
|
@ -297,6 +297,7 @@ _stat(const char *path, Stat *st)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char line[4096];
|
char line[4096];
|
||||||
int dummy, res = 0;
|
int dummy, res = 0;
|
||||||
|
static long tck = 0;
|
||||||
static int64_t boot_time = 0;
|
static int64_t boot_time = 0;
|
||||||
|
|
||||||
if (!boot_time) boot_time = _boot_time();
|
if (!boot_time) boot_time = _boot_time();
|
||||||
|
@ -327,8 +328,11 @@ _stat(const char *path, Stat *st)
|
||||||
|
|
||||||
if (res != 42) return 0;
|
if (res != 42) return 0;
|
||||||
|
|
||||||
st->start_time /= sysconf(_SC_CLK_TCK);
|
if (!tck) tck = sysconf(_SC_CLK_TCK);
|
||||||
|
|
||||||
|
st->start_time /= tck;
|
||||||
st->start_time += boot_time;
|
st->start_time += boot_time;
|
||||||
|
st->run_time = (st->utime + st->stime) / tck;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -366,6 +370,7 @@ _process_list_linux_get(void)
|
||||||
p->uid = _uid(pid);
|
p->uid = _uid(pid);
|
||||||
p->cpu_id = st.psr;
|
p->cpu_id = st.psr;
|
||||||
p->start = st.start_time;
|
p->start = st.start_time;
|
||||||
|
p->run_time = st.run_time;
|
||||||
p->state = _process_state_name(st.state);
|
p->state = _process_state_name(st.state);
|
||||||
p->cpu_time = st.utime + st.stime;
|
p->cpu_time = st.utime + st.stime;
|
||||||
p->nice = st.nice;
|
p->nice = st.nice;
|
||||||
|
@ -436,6 +441,7 @@ proc_info_by_pid(int pid)
|
||||||
p->uid = _uid(pid);
|
p->uid = _uid(pid);
|
||||||
p->cpu_id = st.psr;
|
p->cpu_id = st.psr;
|
||||||
p->start = st.start_time;
|
p->start = st.start_time;
|
||||||
|
p->run_time = st.run_time;
|
||||||
p->state = _process_state_name(st.state);
|
p->state = _process_state_name(st.state);
|
||||||
p->cpu_time = st.utime + st.stime;
|
p->cpu_time = st.utime + st.stime;
|
||||||
p->priority = st.pri;
|
p->priority = st.pri;
|
||||||
|
|
|
@ -20,6 +20,7 @@ typedef struct _Proc_Info
|
||||||
int32_t numthreads;
|
int32_t numthreads;
|
||||||
int64_t cpu_time;
|
int64_t cpu_time;
|
||||||
double cpu_usage;
|
double cpu_usage;
|
||||||
|
int64_t run_time;
|
||||||
int64_t start;
|
int64_t start;
|
||||||
|
|
||||||
uint64_t mem_size;
|
uint64_t mem_size;
|
||||||
|
|
|
@ -32,6 +32,7 @@ typedef struct
|
||||||
Evas_Object *entry_pid_shared;
|
Evas_Object *entry_pid_shared;
|
||||||
Evas_Object *entry_pid_size;
|
Evas_Object *entry_pid_size;
|
||||||
Evas_Object *entry_pid_started;
|
Evas_Object *entry_pid_started;
|
||||||
|
Evas_Object *entry_pid_run_time;
|
||||||
Evas_Object *entry_pid_nice;
|
Evas_Object *entry_pid_nice;
|
||||||
Evas_Object *entry_pid_pri;
|
Evas_Object *entry_pid_pri;
|
||||||
Evas_Object *entry_pid_state;
|
Evas_Object *entry_pid_state;
|
||||||
|
@ -518,20 +519,6 @@ _threads_cpu_usage(Ui_Data *pd, Proc_Info *proc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
|
||||||
_time_string(int64_t epoch)
|
|
||||||
{
|
|
||||||
struct tm *info;
|
|
||||||
time_t rawtime;
|
|
||||||
char buf[256];
|
|
||||||
|
|
||||||
rawtime = (time_t) epoch;
|
|
||||||
info = localtime(&rawtime);
|
|
||||||
strftime(buf, sizeof(buf), "%F %T", info);
|
|
||||||
|
|
||||||
return strdup(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_item_children_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
_item_children_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
void *event_info)
|
void *event_info)
|
||||||
|
@ -797,6 +784,28 @@ _graph(Evas_Object *parent, Ui_Data *pd)
|
||||||
return tbl;
|
return tbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
_time_string(int64_t epoch)
|
||||||
|
{
|
||||||
|
struct tm *info;
|
||||||
|
time_t rawtime;
|
||||||
|
char buf[256];
|
||||||
|
|
||||||
|
rawtime = (time_t) epoch;
|
||||||
|
info = localtime(&rawtime);
|
||||||
|
strftime(buf, sizeof(buf), "%F %T", info);
|
||||||
|
|
||||||
|
return strdup(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
_run_time_string(int64_t secs)
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
snprintf(buf, sizeof(buf), "%ld:%02ld", secs / 60, secs % 60);
|
||||||
|
return strdup(buf);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_proc_gone(Ui_Data *pd)
|
_proc_gone(Ui_Data *pd)
|
||||||
{
|
{
|
||||||
|
@ -911,8 +920,13 @@ _proc_info_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
|
||||||
evisum_size_format(proc->mem_shared));
|
evisum_size_format(proc->mem_shared));
|
||||||
#endif
|
#endif
|
||||||
elm_object_text_set(pd->entry_pid_size, evisum_size_format(proc->mem_size));
|
elm_object_text_set(pd->entry_pid_size, evisum_size_format(proc->mem_size));
|
||||||
|
char *t = _run_time_string(proc->run_time);
|
||||||
char *t = _time_string(proc->start);
|
if (t)
|
||||||
|
{
|
||||||
|
elm_object_text_set(pd->entry_pid_run_time, t);
|
||||||
|
free(t);
|
||||||
|
}
|
||||||
|
t = _time_string(proc->start);
|
||||||
if (t)
|
if (t)
|
||||||
{
|
{
|
||||||
elm_object_text_set(pd->entry_pid_started, t);
|
elm_object_text_set(pd->entry_pid_started, t);
|
||||||
|
@ -1108,6 +1122,11 @@ _process_tab_add(Evas_Object *parent, Ui_Data *pd)
|
||||||
pd->entry_pid_started = entry = _entry_add(parent);
|
pd->entry_pid_started = entry = _entry_add(parent);
|
||||||
elm_table_pack(tbl, entry, 1, i++, 1, 1);
|
elm_table_pack(tbl, entry, 1, i++, 1, 1);
|
||||||
|
|
||||||
|
lb = _lb_add(parent, _(" Run time:"));
|
||||||
|
elm_table_pack(tbl, lb, 0, i, 1, 1);
|
||||||
|
pd->entry_pid_run_time = entry = _entry_add(parent);
|
||||||
|
elm_table_pack(tbl, entry, 1, i++, 1, 1);
|
||||||
|
|
||||||
lb = _lb_add(parent, _("Nice:"));
|
lb = _lb_add(parent, _("Nice:"));
|
||||||
elm_table_pack(tbl, lb, 0, i, 1, 1);
|
elm_table_pack(tbl, lb, 0, i, 1, 1);
|
||||||
pd->entry_pid_nice = entry = _entry_add(parent);
|
pd->entry_pid_nice = entry = _entry_add(parent);
|
||||||
|
|
Loading…
Reference in New Issue