BlinkenArea - GitList
Repositories
Blog
Wiki
uproctrace
Code
Commits
Branches
Tags
Search
Tree:
2693fd1
Branches
Tags
master
uproctrace
libuptev
src
timing.c
implement user/sys time + max rss
Stefan Schuermans
commited
2693fd1
at 2020-05-21 12:27:46
timing.c
Blame
History
Raw
#include "timing.h" #include <uproctrace.pb-c.h> #include <sys/time.h> #include <time.h> void uptev_timing_timeval_to_pb(struct timeval const *tv, struct _Uproctrace__Timespec *tsp) { tsp->sec = tv->tv_sec; tsp->has_nsec = 1; tsp->nsec = tv->tv_usec * 1000; } void uptev_timing_timespec_to_pb(struct timespec const *ts, struct _Uproctrace__Timespec *tsp) { tsp->sec = ts->tv_sec; tsp->has_nsec = 1; tsp->nsec = ts->tv_nsec; } void uptev_timing_get_timestamp(struct _Uproctrace__Timespec *timestamp) { struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); uptev_timing_timespec_to_pb(&ts, timestamp); } void uptev_timing_get_proc_cpu_time( struct _Uproctrace__Timespec *proc_cpu_time) { struct timespec ts; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts); uptev_timing_timespec_to_pb(&ts, proc_cpu_time); }