commit 1d26cbd8ca138b1294411c3af7dbf2eb1268b418
parent f00bfc8fa7c73e6c58dc71d2da4555ce1712aef4
Author: Frederic Cambus <fred@statdns.com>
Date: Sun, 24 May 2020 10:38:21 +0200
Display processing time on exit.
Diffstat:
1 file changed, 14 insertions(+), 0 deletions(-)
diff --git a/src/ansilove.c b/src/ansilove.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#ifdef HAVE_SECCOMP
#include <sys/prctl.h>
@@ -74,6 +75,8 @@ main(int argc, char *argv[])
char *type = NULL;
int filetype = 0;
+ struct timespec begin, end, elapsed;
+
static struct ansilove_ctx ctx;
static struct ansilove_options options;
@@ -182,6 +185,9 @@ main(int argc, char *argv[])
if (!messages)
messages = stdout;
+ /* Starting timer */
+ clock_gettime(CLOCK_MONOTONIC, &begin);
+
/* let's check the file for a valid SAUCE record */
struct sauce *record = sauceReadFileName(input);
@@ -325,6 +331,14 @@ main(int argc, char *argv[])
}
}
+ /* Stopping timer */
+ clock_gettime(CLOCK_MONOTONIC, &end);
+
+ timespecsub(&end, &begin, &elapsed);
+
+ fprintf(messages, "\nProcessed in %f seconds.\n",
+ elapsed.tv_sec + elapsed.tv_nsec / 1E9);
+
ansilove_clean(&ctx);
free(record->comment_lines);