diff --git a/VERSION b/VERSION index 50c76ef..69626fb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.10 +0.5.11 diff --git a/meson.build b/meson.build index 0b37499..160deab 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ ##### Project project('evisum', 'c', - version : '0.5.10', + version : '0.5.11', meson_version : '>= 0.40.0') efl_version = '>= 1.22.0' diff --git a/src/bin/system/process.c b/src/bin/system/process.c index 18e9637..709c0c4 100644 --- a/src/bin/system/process.c +++ b/src/bin/system/process.c @@ -284,7 +284,7 @@ _boot_time(void) typedef struct { int pid, ppid, utime, stime, cutime, cstime; int psr, pri, nice, numthreads; - long long int start_time; + long long int start_time, run_time; char state; unsigned int mem_rss, flags; unsigned long mem_virt; @@ -297,6 +297,7 @@ _stat(const char *path, Stat *st) FILE *f; char line[4096]; int dummy, res = 0; + static long tck = 0; static int64_t boot_time = 0; if (!boot_time) boot_time = _boot_time(); @@ -327,8 +328,11 @@ _stat(const char *path, Stat *st) 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->run_time = (st->utime + st->stime) / tck; return 1; } @@ -366,6 +370,7 @@ _process_list_linux_get(void) p->uid = _uid(pid); p->cpu_id = st.psr; p->start = st.start_time; + p->run_time = st.run_time; p->state = _process_state_name(st.state); p->cpu_time = st.utime + st.stime; p->nice = st.nice; @@ -436,6 +441,7 @@ proc_info_by_pid(int pid) p->uid = _uid(pid); p->cpu_id = st.psr; p->start = st.start_time; + p->run_time = st.run_time; p->state = _process_state_name(st.state); p->cpu_time = st.utime + st.stime; p->priority = st.pri; diff --git a/src/bin/system/process.h b/src/bin/system/process.h index 0d39879..f5c4ea1 100644 --- a/src/bin/system/process.h +++ b/src/bin/system/process.h @@ -20,6 +20,7 @@ typedef struct _Proc_Info int32_t numthreads; int64_t cpu_time; double cpu_usage; + int64_t run_time; int64_t start; uint64_t mem_size; diff --git a/src/bin/ui/ui_process_view.c b/src/bin/ui/ui_process_view.c index 50d3003..28c63fd 100644 --- a/src/bin/ui/ui_process_view.c +++ b/src/bin/ui/ui_process_view.c @@ -32,6 +32,7 @@ typedef struct Evas_Object *entry_pid_shared; Evas_Object *entry_pid_size; Evas_Object *entry_pid_started; + Evas_Object *entry_pid_run_time; Evas_Object *entry_pid_nice; Evas_Object *entry_pid_pri; 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 _item_children_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) @@ -797,6 +784,28 @@ _graph(Evas_Object *parent, Ui_Data *pd) 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 _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)); #endif elm_object_text_set(pd->entry_pid_size, evisum_size_format(proc->mem_size)); - - char *t = _time_string(proc->start); + char *t = _run_time_string(proc->run_time); + if (t) + { + elm_object_text_set(pd->entry_pid_run_time, t); + free(t); + } + t = _time_string(proc->start); if (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); 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:")); elm_table_pack(tbl, lb, 0, i, 1, 1); pd->entry_pid_nice = entry = _entry_add(parent);