From aeb3479c40c17c67476ef203e6c8fabe6c5c0d58 Mon Sep 17 00:00:00 2001
From: 13512501 <13512501@hpc.if.itb.ac.id>
Date: Fri, 19 Feb 2016 10:56:41 +0700
Subject: [PATCH] add pengukur waktu di openmp.c

---
 bucket_sort_openmp.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/bucket_sort_openmp.c b/bucket_sort_openmp.c
index 6e8fd0c..6635599 100644
--- a/bucket_sort_openmp.c
+++ b/bucket_sort_openmp.c
@@ -5,13 +5,14 @@
 #include <assert.h>
 #include <limits.h>
 #include <string.h>
+#include <time.h>
 
 #include "random.c"
 
 #include "insertion_sort_func.c"
 
 void sort(int * arr, int len){
-	insertion_sort(arr,len);
+        insertion_sort(arr,len);
 }
 
 int main(int argc, char ** argv){
@@ -21,11 +22,16 @@ int main(int argc, char ** argv){
             exit(1);
     }
     
+		clock_t start, end, total;
+		
+		
+		
+    
         int thread_count =strtol(argv[1],NULL,10);
     
-	int * compl_arr;
-	int i,j;
-		int num_elmts;
+        int * compl_arr;
+        int i,j;
+                int num_elmts;
 
         //input
         scanf("%d",&num_elmts);
@@ -39,11 +45,11 @@ int main(int argc, char ** argv){
             printf("%d ", compl_arr[i]);
         }
         printf("\n");
-
-	//bagi-bagi
-	int * num_elmts_in_buckets;
-	int * buckets_bin;
-	int ** buckets;
+		start = clock();
+        //bagi-bagi
+        int * num_elmts_in_buckets;
+        int * buckets_bin;
+        int ** buckets;
 
         num_elmts_in_buckets = (int*) malloc(thread_count*sizeof(int));
         buckets = (int**) malloc(thread_count*sizeof(int*));
@@ -79,12 +85,14 @@ int main(int argc, char ** argv){
             //copy
             memcpy(&compl_arr[bucket_offset[i]],buckets[i],num_elmts_in_buckets[i]*sizeof(int));
         }
-
+		end = clock();
+		total = end - start;
+		
         for (i=0;i<num_elmts;i++){
             printf("%d ", compl_arr[i]);
         }
         printf("\n");
-        
+        printf("Total waktu %f",(double)total/CLOCKS_PER_SEC);
         free(bucket_offset);
         free(num_elmts_in_buckets);
         for (i=0;i<thread_count;i++)
-- 
GitLab