From 79b5ed00da523d84380ddf7d8706b12d8cdb429e Mon Sep 17 00:00:00 2001 From: Mattia Cabrini Date: Tue, 9 Sep 2025 17:50:14 +0200 Subject: [PATCH] +Time; +Fix Makefile --- Makefile | 2 +- cmc-find.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 932d77d..e47a0f1 100644 --- a/Makefile +++ b/Makefile @@ -21,4 +21,4 @@ fmt: indent $(INDEND_FLAGS) $(SRC) run: # on Unix-like systems... - cat /dev/urandom | ./find 1606 + cat /dev/urandom | ./$(BIN) 1606 diff --git a/cmc-find.c b/cmc-find.c index 78a8372..c06cd26 100644 --- a/cmc-find.c +++ b/cmc-find.c @@ -5,6 +5,7 @@ #include #include #include +#include #ifndef MAX_LEN #define MAX_LEN 64 @@ -27,6 +28,7 @@ int main(int argc, char **argv) { int ch = 0; uint64_t n; + time_t now; char str[MAX_LEN]; struct cs_t matcher; @@ -38,6 +40,7 @@ int main(int argc, char **argv) strncpy(str, argv[1], sizeof(str)); printf("Check against %s\n", str); + now = time(0); cs_init(&matcher, strlen(str)); for (n = 1; (ch = fgetc(stdin)) != EOF; ++n) { @@ -45,7 +48,7 @@ int main(int argc, char **argv) if (matcher.len == matcher.cap) { if (cs_cmp(&matcher, str)) { - printf("Found at %llu\n", n - matcher.cap); + printf("Found at %llu\t%lu\n", n - matcher.cap, time(0) - now); /* cs_print(&matcher); printf("\n"); */ } } -- 2.43.0