From dc26ae0b913ff49ecbf0f653b4baffa7a37f2303 Mon Sep 17 00:00:00 2001 From: A404M Date: Fri, 25 Apr 2025 22:22:40 +0330 Subject: add better time printing --- src/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 273f4ec..1e04d0b 100644 --- a/src/main.c +++ b/src/main.c @@ -11,12 +11,14 @@ static int run(const char *filePath) { #ifdef PRINT_STATISTICS struct timespec start, end; + struct timespec lexTime = {0}; + struct timespec parseTime = {0}; struct timespec astTime; struct timespec runTime; struct timespec totalTime = {0}; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); #endif - AstTreeRoots astTrees = makeAstTree(filePath); + AstTreeRoots astTrees = makeAstTree(filePath, &lexTime, &parseTime); if (astTrees.size == AST_TREE_ROOTS_ERROR.size) { return 1; } @@ -48,6 +50,12 @@ static int run(const char *filePath) { #endif #ifdef PRINT_STATISTICS + astTime = time_diff(astTime, parseTime); + parseTime = time_diff(parseTime, lexTime); + printf("\nlexTime: "); + time_print(lexTime); + printf("\nparseTime: "); + time_print(parseTime); printf("\nastTime: "); time_print(astTime); printf("\nrunTime: "); -- cgit v1.2.3