indent $(INDEND_FLAGS) $(SRC)
run: # on Unix-like systems...
- cat /dev/urandom | ./find 1606
+ cat /dev/urandom | ./$(BIN) 1606
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
+#include <time.h>
#ifndef MAX_LEN
#define MAX_LEN 64
{
int ch = 0;
uint64_t n;
+ time_t now;
char str[MAX_LEN];
struct cs_t matcher;
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) {
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"); */
}
}