]> git repos ~mattia - cmc-find.git/commitdiff
+Time; +Fix Makefile
authorMattia Cabrini <dev@mattiacabrini.com>
Tue, 9 Sep 2025 15:50:14 +0000 (17:50 +0200)
committerMattia Cabrini <dev@mattiacabrini.com>
Tue, 9 Sep 2025 15:50:14 +0000 (17:50 +0200)
Makefile
cmc-find.c

index 932d77dfff52dbe5dc53fe4c91e3acb38d00ddff..e47a0f16528e8d15df7b54efd976fc353425b551 100644 (file)
--- 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
index 78a8372b6354297f9ed8a2775c7790929358eeea..c06cd269b8ae35202f34cd2eece19300c7d7338c 100644 (file)
@@ -5,6 +5,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
+#include <time.h>
 
 #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"); */
                        }
                }