advent2025

Advent of Code 2025 Solutions
git clone git://bsandro.tech/advent2025
Log | Files | Refs | LICENSE

commit 8665aa1f238c77ed5b0257987f5ab17de80a81a0
parent ce9a85fe725d5b64306da9cf9e08336c3f3cd347
Author: bsandro <email@bsandro.tech>
Date:   Mon,  1 Dec 2025 19:22:09 +0200

cputime is monotonic now

Diffstat:
Mcputime.h | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/cputime.h b/cputime.h @@ -3,12 +3,12 @@ static volatile unsigned long long now = 0; void __attribute((constructor)) begin() { struct timespec ts; - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts); + clock_gettime(CLOCK_MONOTONIC_RAW, &ts); now = ts.tv_sec + ts.tv_nsec; } void __attribute((destructor)) end() { struct timespec ts; - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts); - printf("%lluμs\n", ((ts.tv_sec+ts.tv_nsec)-now)/1000); + clock_gettime(CLOCK_MONOTONIC_RAW, &ts); + printf("%llu μs\n", ((ts.tv_sec+ts.tv_nsec)-now)/1000); }