Skip to content
Snippets Groups Projects
Commit 665599fe authored by 13513022's avatar 13513022
Browse files

Menambah timer pada program dan menambah laporan

parent d42216e7
No related merge requests found
File added
File added
...@@ -34,6 +34,8 @@ int main(int argc, char *argv[]) { ...@@ -34,6 +34,8 @@ int main(int argc, char *argv[]) {
int i,j; int i,j;
int num_elements = atoi(argv[1]); int num_elements = atoi(argv[1]);
time_t time_count;
MPI_Status Stat; MPI_Status Stat;
MPI_Init(NULL, NULL); MPI_Init(NULL, NULL);
...@@ -53,6 +55,9 @@ int main(int argc, char *argv[]) { ...@@ -53,6 +55,9 @@ int main(int argc, char *argv[]) {
float *rand_nums = NULL; float *rand_nums = NULL;
rand_nums = create_rand_nums(num_elements); rand_nums = create_rand_nums(num_elements);
// Timer
time_count = clock();
// Bagi elemen tersebut ke dalam bucket // Bagi elemen tersebut ke dalam bucket
for (i = 0; i < world_size; ++i) { for (i = 0; i < world_size; ++i) {
for (j = 0; j < num_elements; ++j) { for (j = 0; j < num_elements; ++j) {
...@@ -120,10 +125,13 @@ int main(int argc, char *argv[]) { ...@@ -120,10 +125,13 @@ int main(int argc, char *argv[]) {
} }
// Print array yang sudah terurut; // Print array yang sudah terurut;
printf("Element yang sudah terurut:\n"); printf("Element sudah terurut.\n");
for (j = 0; j < num_elements; ++j) { // for (j = 0; j < num_elements; ++j) {
printf("%f\n", sorted_array[j]); // printf("%f\n", sorted_array[j]);
} // }
float final_time = (float) (clock()-time_count) / CLOCKS_PER_SEC *1000;
printf("Time : %f ms\n", final_time);
} }
MPI_Finalize(); MPI_Finalize();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment