BUGFIX:
authorgkostka <kostka.grzegorz@gmail.com>
Sun, 27 Oct 2013 12:12:35 +0000 (12:12 +0000)
committergkostka <kostka.grzegorz@gmail.com>
Sun, 27 Oct 2013 12:12:35 +0000 (12:12 +0000)
1. Timing function.

demos/generic/main.c

index 25c040bfdbbfc3a4f21d01ca32532e28bac9c033..a9d4f114c1d5359323a0325ab846fbba5e7e34d8 100644 (file)
@@ -200,6 +200,11 @@ static void block_stats(void)
     printf("**********************************************\n");\r
 }\r
 \r
+static clock_t get_ms(void)\r
+{\r
+    return (clock() * 1000) / (CLOCKS_PER_SEC);\r
+}\r
+\r
 static bool dir_test(int len)\r
 {\r
     ext4_file f;\r
@@ -209,7 +214,7 @@ static bool dir_test(int len)
     clock_t diff;\r
     clock_t stop;\r
     clock_t start;\r
-    start = clock() / (CLOCKS_PER_SEC / 1000);\r
+    start = get_ms();\r
 \r
     printf("Directory create: /mp/dir1\n");\r
     r = ext4_dir_mk("/mp/dir1");\r
@@ -229,7 +234,7 @@ static bool dir_test(int len)
         }\r
     }\r
 \r
-    stop = clock() / (CLOCKS_PER_SEC / 1000);\r
+    stop =  get_ms();\r
     diff = stop - start;\r
     dir_ls("/mp/dir1");\r
     printf("dir_test time: %d ms\n", (int)diff);\r
@@ -256,7 +261,7 @@ static bool file_test(void)
 \r
     printf("ext4_fopen: test1\n");\r
 \r
-    start = clock() / (CLOCKS_PER_SEC / 1000);\r
+    start = get_ms();\r
     r = ext4_fopen(&f, "/mp/test1", "wb");\r
     if(r != EOK){\r
         printf("ext4_fopen ERROR = %d\n", r);\r
@@ -280,7 +285,7 @@ static bool file_test(void)
     }\r
 \r
     printf("OK\n");\r
-    stop = clock() / (CLOCKS_PER_SEC / 1000);\r
+    stop = get_ms();\r
     diff = stop - start;\r
     size_bytes = rw_szie * rw_count;\r
     size_bytes = (size_bytes * 1000) / 1024;\r
@@ -291,7 +296,7 @@ static bool file_test(void)
     printf("ext4_fopen: test1\n");\r
 \r
 \r
-    start = clock() / (CLOCKS_PER_SEC / 1000);\r
+    start = get_ms();\r
     r = ext4_fopen(&f, "/mp/test1", "r+");\r
     if(r != EOK){\r
         printf("ext4_fopen ERROR = %d\n", r);\r
@@ -316,7 +321,7 @@ static bool file_test(void)
         return false;\r
     }\r
     printf("OK\n");\r
-    stop = clock() / (CLOCKS_PER_SEC / 1000);\r
+    stop = get_ms();\r
     diff = stop - start;\r
     size_bytes = rw_szie * rw_count;\r
     size_bytes = (size_bytes * 1000) / 1024;\r
@@ -337,17 +342,17 @@ static void cleanup(void)
     ext4_fremove("/mp/hello.txt");\r
 \r
     printf("cleanup: remove /mp/test1\n");\r
-    start = clock() / (CLOCKS_PER_SEC / 1000);\r
+    start = get_ms();\r
     ext4_fremove("/mp/test1");\r
-    stop = clock() / (CLOCKS_PER_SEC / 1000);\r
+    stop = get_ms();\r
     diff = stop - start;\r
     printf("cleanup: time: %d ms\n", (int)diff);\r
 \r
 \r
     printf("cleanup: remove /mp/test1\n");\r
-    start = clock() / (CLOCKS_PER_SEC / 1000);\r
+    start =get_ms();\r
     ext4_dir_rm("/mp/dir1");\r
-    stop = clock() / (CLOCKS_PER_SEC / 1000);\r
+    stop = get_ms();\r
     diff = stop - start;\r
     printf("cleanup: time: %d ms\n", (int)diff);\r
 }\r