new time interval

This commit is contained in:
Raffaele Mignone 2021-03-26 17:53:23 +01:00
parent b1c6e48b16
commit 43dfc1ea17
Signed by: norangebit
GPG Key ID: F5255658CB220573
2 changed files with 8 additions and 3 deletions

5
main.c
View File

@ -43,6 +43,7 @@ int main() {
MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_rank(MPI_COMM_WORLD, &rank);
long_long start_time = PAPI_get_real_usec();
if (rank == MASTER) if (rank == MASTER)
initialize(); initialize();
@ -61,6 +62,7 @@ int main() {
// search for matches // search for matches
int match_number = 0; int match_number = 0;
int residue; int residue;
long_long start_search = PAPI_get_real_usec();
int *matches = search_pattern(private_text, pattern, lps, &match_number, &residue); int *matches = search_pattern(private_text, pattern, lps, &match_number, &residue);
search_for_splitted_pattern(&residue, &match_number, &matches); search_for_splitted_pattern(&residue, &match_number, &matches);
@ -79,7 +81,8 @@ int main() {
printf("total matches: %d\n", total_match_number); printf("total matches: %d\n", total_match_number);
printf("matches index: "); printf("matches index: ");
print_array(total_matches, total_match_number); print_array(total_matches, total_match_number);
printf("elapsed: %d\n", end_time - start_time); printf("total elapsed: %d\n", end_time - start_time);
printf("search elapsed: %d\n", end_time - start_search);
} }
} }

View File

@ -6,6 +6,7 @@
int main() { int main() {
int text_len, pattern_len; int text_len, pattern_len;
long_long start_time = PAPI_get_real_usec();
char *text = read_file("data/dante.txt", &text_len); char *text = read_file("data/dante.txt", &text_len);
char *pattern = read_file("data/pattern.txt", &pattern_len); char *pattern = read_file("data/pattern.txt", &pattern_len);
@ -15,10 +16,11 @@ int main() {
int match_number = 0; int match_number = 0;
int residue = 0; int residue = 0;
long_long start_time = PAPI_get_real_usec(); long_long start_search = PAPI_get_real_usec();
int *matches = search_pattern(text, pattern, lps, &match_number, &residue); int *matches = search_pattern(text, pattern, lps, &match_number, &residue);
long_long end_time = PAPI_get_real_usec(); long_long end_time = PAPI_get_real_usec();
printf("found %d matches\n", match_number); printf("found %d matches\n", match_number);
printf("elapsed: %d\n", end_time - start_time); printf("total elapsed: %d\n", end_time - start_time);
printf("search elapsed: %d\n", end_time - start_search);
} }