summaryrefslogtreecommitdiff
path: root/src/log.c
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2022-06-07 13:47:35 +0100
committerPhil Jones <philj56@gmail.com>2022-06-07 15:31:49 +0100
commit51bbf779ba2c9d5954e2c9470a8eae7c1ddd38a5 (patch)
treef2b52f0211f9052fefa64e23c6a0d81305391589 /src/log.c
parent7562d7b539d8013376de2cff494231ba307f4ee1 (diff)
Switch from using (E)GL to wl_shm.
eglInitialize() is slow (~50-100ms), and uses a fair amount of memory (~100 MB). For such a small, simple program that just wants to launch as quickly as possible, wl_shm performs better.
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/log.c b/src/log.c
index a6c9a75..065d5be 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1,6 +1,7 @@
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
+#include <sys/resource.h>
#include <time.h>
#define SECOND 1000000000ul
@@ -34,7 +35,7 @@ void log_debug(const char *const fmt, ...)
#endif
static struct timespec start_time;
if (start_time.tv_nsec == 0) {
- fprintf(stderr, "[ real, cpu]\n");
+ fprintf(stderr, "[ real, cpu, maxRSS]\n");
clock_gettime(CLOCK_REALTIME, &start_time);
}
struct timespec real_time;
@@ -42,15 +43,21 @@ void log_debug(const char *const fmt, ...)
clock_gettime(CLOCK_REALTIME, &real_time);
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &cpu_time);
real_time = time_diff(real_time, start_time);
+
+ struct rusage usage;
+ getrusage(RUSAGE_SELF, &usage);
+
va_list args;
va_start(args, fmt);
fprintf(
stderr,
- "[%ld.%03ld, %ld.%03ld][DEBUG]: ",
+ "[%ld.%03ld, %ld.%03ld, %ld KB][DEBUG]: ",
real_time.tv_sec,
real_time.tv_nsec / 1000000,
cpu_time.tv_sec,
- cpu_time.tv_nsec / 1000000);
+ cpu_time.tv_nsec / 1000000,
+ usage.ru_maxrss
+ );
vfprintf(stderr, fmt, args);
va_end(args);
}