diff --git a/bucketsort.c b/bucketsort.c index d00dbac3ef00396af5cf1a441d072953590da744..f3b7df98a1ef1d8eedc02f2782d0d08c846d975c 100644 --- a/bucketsort.c +++ b/bucketsort.c @@ -121,27 +121,39 @@ int main(int argc, char *argv[]) { int *sorted_all[thread_count]; int sorted_size[thread_count]; + clock_t begin, end; + double time_spent; + + begin = clock(); // Bikin bucket buat memecah pecah masalah jadi lebih kecil buckets = createBucket(array, searchMax(array,array_size), array_size, thread_count); //printBucket(buckets[0]); + end = clock(); + time_spent = (double)(end- begin ) / CLOCKS_PER_SEC; + printf("Time pembagian: %f", time_spent); + + begin = clock(); #pragma omp parallel num_threads(thread_count) { Hello(&(*sorted_all), &sorted_size); } + end = clock(); + time_spent = (double)(end- begin ) / CLOCKS_PER_SEC; - int i = 0; + printf("Time spent: %f", time_spent); + //int i = 0; +/* for (i = 0; i < thread_count; i++) { printArray(sorted_all[i], sorted_size[i]); } - +*/ return 0; } void Hello(int **sorted_all, int *sorted_size) { int my_rank = omp_get_thread_num(); - int thread_count = omp_get_num_threads(); int *sorted = insertionSort(buckets[my_rank].content, buckets[my_rank].size);