Add sequential
This commit is contained in:
parent
f312ca2205
commit
4f03fc2d5b
19567
data/dante.txt
Normal file
19567
data/dante.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
|||||||
mamma
|
stella
|
||||||
|
@ -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
24
sequential.c
Normal 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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user