Add sequential

This commit is contained in:
Raffaele Mignone 2021-03-26 17:32:20 +01:00
parent f312ca2205
commit 4f03fc2d5b
Signed by: norangebit
GPG Key ID: F5255658CB220573
4 changed files with 19594 additions and 2 deletions

19567
data/dante.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
mamma
stella

View File

@ -1 +1,2 @@
testo di esempio mamma altra mamma esempio prova mammamma esempio mamma
testo di esem
pio mamma altra mamma esempio prova mammamma esempio mamma

24
sequential.c Normal file
View File

@ -0,0 +1,24 @@
#include "util.h"
#include "kmp.h"
#include <stdio.h>
#include <papi.h>
int main() {
int text_len, pattern_len;
char *text = read_file("data/dante.txt", &text_len);
char *pattern = read_file("data/pattern.txt", &pattern_len);
int lps[pattern_len];
create_lps(pattern, pattern_len, lps);
int match_number = 0;
int residue = 0;
long_long start_time = PAPI_get_real_usec();
int *matches = search_pattern(text, pattern, lps, &match_number, &residue);
long_long end_time = PAPI_get_real_usec();
printf("found %d matches\n", match_number);
printf("elapsed: %d\n", end_time - start_time);
}