From bbcc41762f335e90dc850dd9d4a6cc5e51631c7c Mon Sep 17 00:00:00 2001 From: grm Date: Mon, 16 Dec 2024 14:02:21 +0200 Subject: upkeep --- b.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'b.c') diff --git a/b.c b/b.c index 22a2304..89ea2ce 100644 --- a/b.c +++ b/b.c @@ -210,9 +210,29 @@ build_objects(const char* lang, return true; } +#include +float +current_time() +{ + static struct timespec startTime; + static int isStartTimeInitialized = 0; + + if (!isStartTimeInitialized) { + clock_gettime(CLOCK_MONOTONIC, &startTime); + isStartTimeInitialized = 1; + } + + struct timespec currentTime; + clock_gettime(CLOCK_MONOTONIC, ¤tTime); + + return (currentTime.tv_sec - startTime.tv_sec) + + (currentTime.tv_nsec - startTime.tv_nsec) / 1e9f; +} + int main(int argc, char *argv[]) { + float before_build = current_time(); B_GO_REBUILD_URSELF(argc, argv); const char *program_name = b_shift_args(&argc, &argv); @@ -275,6 +295,8 @@ main(int argc, char *argv[]) if (!build_objects("C++", "src/cplusplus.cpp", cplusplus_deps, B_ARRAY_LEN(cplusplus_deps), objects, &it)) return 1; if (!build_c(force, &cmd, render_paths, B_ARRAY_LEN(render_paths), render_deps, B_ARRAY_LEN(render_deps), objects, B_ARRAY_LEN(objects), BUILD_DIR"render")) return 1; + b_log(B_INFO, "Build time: %.3f seconds", current_time() - before_build); + return 0; } /* -- cgit v1.2.3