From 3b4f9ae515f421c6f4509cfe9caa4b2415f1adb9 Mon Sep 17 00:00:00 2001
From: Christian C <cc@localhost>
Date: Wed, 5 Mar 2025 12:58:42 -0800
Subject: Timing macro

---
 include/lib/time.h | 2 ++
 src/main.c         | 7 ++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/lib/time.h b/include/lib/time.h
index fd3c6be..9d69b44 100644
--- a/include/lib/time.h
+++ b/include/lib/time.h
@@ -3,6 +3,8 @@
 
 #include <time.h>
 
+#define TIME(var) struct timespec var;get_time(&var)
+
 // Difference in Time
 // Compute the difference between timespec structs
 double diff_time(struct timespec *time1, struct timespec *time0);
diff --git a/src/main.c b/src/main.c
index 02f5520..abfc57f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -13,6 +13,8 @@
 
 #define OFFSET 16
 
+#define N_DILATIONS 3
+
 int main(int argc, char** argv)
 {
   //-----------------------------------------------
@@ -54,11 +56,14 @@ int main(int argc, char** argv)
   }
   printf("%u labels found\n", starting_label-1);
   printf("Mask dimensions: %u %u\n", width, height);
-  for (uint16_t count = 0; count < 3; count++) {
+  TIME(ts_start);
+  for (uint16_t count = 0; count < N_DILATIONS; count++) {
     uint16_t *new_labels = dilate(masks, width, height);
     free(masks);
     masks = new_labels;
   }
+  TIME(ts_end);
+  printf("Dilation took %f ms\n", 1000*diff_time(&ts_end, &ts_start));
   //free(masks);
   //-----------------------------------------------
 
-- 
cgit v1.2.1