2693fd1543b138ac960e49d8a03afd384bc45ed1
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

1) #include "timing.h"
2) 
3) #include <uproctrace.pb-c.h>
4) 
Stefan Schuermans implement user/sys time + m...

Stefan Schuermans authored 4 years ago

5) #include <sys/time.h>
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

6) #include <time.h>
7) 
Stefan Schuermans implement user/sys time + m...

Stefan Schuermans authored 4 years ago

8) void uptev_timing_timeval_to_pb(struct timeval const *tv,
9)                                 struct _Uproctrace__Timespec *tsp) {
10)   tsp->sec = tv->tv_sec;
11)   tsp->has_nsec = 1;
12)   tsp->nsec = tv->tv_usec * 1000;
13) }
14) 
15) void uptev_timing_timespec_to_pb(struct timespec const *ts,
16)                                  struct _Uproctrace__Timespec *tsp) {
17)   tsp->sec = ts->tv_sec;
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

18)   tsp->has_nsec = 1;
Stefan Schuermans implement user/sys time + m...

Stefan Schuermans authored 4 years ago

19)   tsp->nsec = ts->tv_nsec;
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

20) }
21) 
22) void uptev_timing_get_timestamp(struct _Uproctrace__Timespec *timestamp) {
Stefan Schuermans implement user/sys time + m...

Stefan Schuermans authored 4 years ago

23)   struct timespec ts;
24)   clock_gettime(CLOCK_REALTIME, &ts);
25)   uptev_timing_timespec_to_pb(&ts, timestamp);
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

26) }
27) 
Stefan Schuermans formatting

Stefan Schuermans authored 4 years ago

28) void uptev_timing_get_proc_cpu_time(
29)     struct _Uproctrace__Timespec *proc_cpu_time) {
Stefan Schuermans implement user/sys time + m...

Stefan Schuermans authored 4 years ago

30)   struct timespec ts;
31)   clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
32)   uptev_timing_timespec_to_pb(&ts, proc_cpu_time);