Browse Source

no message

Hongtae Kim 5 years ago
parent
commit
194b9e21c6
2 changed files with 27 additions and 13 deletions
  1. 27
    12
      TestApp1/TestApp1.cpp
  2. 0
    1
      TestApp1/dkgl_new.cpp

+ 27
- 12
TestApp1/TestApp1.cpp View File

@@ -8,7 +8,8 @@
8 8
 #include <algorithm>
9 9
 #include <DK.h>
10 10
 
11
-#define MAX_SIZE 100000000ULL
11
+
12
+#define MAX_SIZE 200000000ULL
12 13
 
13 14
 #ifdef _WIN32
14 15
 int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
@@ -28,14 +29,13 @@ int main(int argc, const char * argv[])
28 29
 		} i32;
29 30
 	};
30 31
 
31
-
32
-
33 32
 	auto testStd = [](Value* val_copy, const Value* input, size_t len)->DKHashResultSHA1
34 33
 	{
35 34
 		DKLogI("Copying buffer...");
36 35
 		memcpy(val_copy, input, sizeof(Value) * len);
37 36
 
38 37
 		DKTimer timer;
38
+		DKThread::Sleep(1.0);
39 39
 		DKLogI("Sorting by std::sort...");
40 40
 		timer.Reset();
41 41
 		std::sort(val_copy, val_copy + MAX_SIZE, [](const Value& lhs, const Value& rhs)->bool
@@ -44,7 +44,9 @@ int main(int argc, const char * argv[])
44 44
 		});
45 45
 		double e1 = timer.Elapsed();
46 46
 
47
-		DKLogI("std::sort: %f", e1);
47
+		DKLogW("std::sort: %f", e1);
48
+		DKThread::Sleep(1.0);
49
+
48 50
 		return DKHashSHA1(val_copy, sizeof(Value)*len);
49 51
 	};
50 52
 	auto testDK = [](Value* val_copy, const Value* input, size_t len)->DKHashResultSHA1
@@ -55,6 +57,7 @@ int main(int argc, const char * argv[])
55 57
 		DKStaticArray<Value> tmp(val_copy, MAX_SIZE);
56 58
 
57 59
 		DKTimer timer;
60
+		DKThread::Sleep(1.0);
58 61
 		DKLogI("Sorting by DKStaticArray::Sort...");
59 62
 		timer.Reset();
60 63
 		tmp.Sort([](const Value& lhs, const Value& rhs)->bool
@@ -63,26 +66,38 @@ int main(int argc, const char * argv[])
63 66
 		});
64 67
 		double e1 = timer.Elapsed();
65 68
 
66
-		DKLogI("DKStaticArray::sort: %f (memCopy:%d)", e1, tmp.UseMemoryCopy);
69
+		DKLogW("DKStaticArray::sort: %f (memCopy:%d)", e1, tmp.CopyMethod);
70
+		DKThread::Sleep(1.0);
71
+
67 72
 		return DKHashSHA1(val_copy, sizeof(Value)*len);
68 73
 	};
69 74
 
70 75
 	DKApplication app;
71
-	DKLog("Allocating buffer...");
72
-
73 76
 	Value* val1 = new Value[MAX_SIZE];
74 77
 
78
+	DKLog("Generating data...1");
75 79
 	for (size_t i = 0; i < MAX_SIZE; ++i)
76 80
 	{
77 81
 		val1[i].i32 = { DKRandom(), DKRandom() };
78 82
 	}
79 83
 	Value* val_copy = new Value[MAX_SIZE];
80 84
 
81
-	DKHashResultSHA1 sha1_r1 = testDK(val_copy, val1, MAX_SIZE);
82
-	DKLogI("Hash1: %ls", (const wchar_t*)sha1_r1.String());
83
-	DKHashResultSHA1 sha1_r2 = testStd(val_copy, val1, MAX_SIZE);
84
-	DKLogI("Hash2: %ls", (const wchar_t*)sha1_r2.String());
85
-	DKLogI("Hash compare:%d", sha1_r1.Compare(sha1_r2));
85
+	auto doTest = [&]() {
86
+		DKHashResultSHA1 sha1_r1 = testDK(val_copy, val1, MAX_SIZE);
87
+		DKLogI("Hash1: %ls", (const wchar_t*)sha1_r1.String());
88
+		DKHashResultSHA1 sha1_r2 = testStd(val_copy, val1, MAX_SIZE);
89
+		DKLogI("Hash2: %ls", (const wchar_t*)sha1_r2.String());
90
+		DKLogI("Hash compare:%d", sha1_r1.Compare(sha1_r2));
91
+	};
92
+	doTest();
93
+
94
+	DKLog("Generating data...2");
95
+	for (size_t i = 0; i < MAX_SIZE; ++i)
96
+	{
97
+		val1[i].i32 = { DKRandom(), DKRandom() };
98
+	}
99
+
100
+	doTest();
86 101
 
87 102
 	delete[] val1;
88 103
 	delete[] val_copy;

+ 0
- 1
TestApp1/dkgl_new.cpp View File

@@ -1,4 +1,3 @@
1
-
2 1
 #include <DK.h>
3 2
 
4 3
 void* operator new (std::size_t size)