Browse Source

no message

Hongtae Kim 6 years ago
parent
commit
047465ce46
1 changed files with 29 additions and 17 deletions
  1. 29
    17
      TestApp1/TestApp1.cpp

+ 29
- 17
TestApp1/TestApp1.cpp View File

9
 #include <DK.h>
9
 #include <DK.h>
10
 
10
 
11
 
11
 
12
-#define MAX_SIZE 50000000ULL
12
+#define MAX_SIZE 80000000ULL
13
 
13
 
14
 struct Value64
14
 struct Value64
15
 {
15
 {
60
 	
60
 	
61
 	DKThread::Sleep(0.2);
61
 	DKThread::Sleep(0.2);
62
 
62
 
63
-	auto testSTL = [](T* val, size_t len)->DKHashResultSHA1
63
+	using ResultTuple = DKTuple<DKHashResultSHA1, double>;
64
+
65
+	auto testSTL = [](T* val, size_t len)->ResultTuple
64
 	{
66
 	{
65
-		DKLogI("Sorting by std::sort...");
67
+		DKLog("Sorting by std::sort...");
66
 		DKTimer timer;
68
 		DKTimer timer;
67
 		timer.Reset();
69
 		timer.Reset();
68
 		std::sort(val, val + len, [](const auto& lhs, const auto& rhs)->bool
70
 		std::sort(val, val + len, [](const auto& lhs, const auto& rhs)->bool
73
 		DKLogW("std::sort: %f", e1);
75
 		DKLogW("std::sort: %f", e1);
74
 		auto hash = DKHashSHA1(val, sizeof(T) * len);
76
 		auto hash = DKHashSHA1(val, sizeof(T) * len);
75
 		DKLog("std::sort hash: %ls", (const wchar_t*)hash.String());
77
 		DKLog("std::sort hash: %ls", (const wchar_t*)hash.String());
76
-		return hash;
78
+		return ResultTuple::Make(hash, e1);
77
 	};
79
 	};
78
 
80
 
79
-	auto testDK = [](T* val, size_t len)->DKHashResultSHA1
81
+	auto testDK = [](T* val, size_t len)->ResultTuple
80
 	{
82
 	{
81
-		DKLogI("Sorting by DKStaticArray::Sort...");
83
+		DKLog("Sorting by DKStaticArray::Sort...");
82
 		DKStaticArray<T> tmp(val, len);
84
 		DKStaticArray<T> tmp(val, len);
83
 		DKTimer timer;
85
 		DKTimer timer;
84
 		timer.Reset();
86
 		timer.Reset();
86
 		{
88
 		{
87
 			return lhs < rhs;
89
 			return lhs < rhs;
88
 		});
90
 		});
89
-		double e2 = timer.Elapsed();
90
-		DKLogW("DKStaticArray::Sort: %f (SwapMethod:%d)", e2, tmp.SwapMethod);
91
+		double e1 = timer.Elapsed();
92
+		DKLogW("DKStaticArray::Sort: %f (SwapMethod:%d)", e1, tmp.SwapMethod);
91
 		auto hash = DKHashSHA1(val, sizeof(T) * len);
93
 		auto hash = DKHashSHA1(val, sizeof(T) * len);
92
 		DKLog("DKStaticArray::Sort hash: %ls", (const wchar_t*)hash.String());
94
 		DKLog("DKStaticArray::Sort hash: %ls", (const wchar_t*)hash.String());
93
-		return hash;
95
+		return ResultTuple::Make(hash, e1);
94
 	};
96
 	};
95
 
97
 
96
 	if (dkFirst)
98
 	if (dkFirst)
97
 	{
99
 	{
98
-		auto hash1 = testDK(val1, MAX_SIZE);
99
-		auto hash2 = testSTL(val2, MAX_SIZE);
100
-		DKLog("Hash compare: %d", hash1.Compare(hash2));
100
+		auto result1 = testDK(val1, MAX_SIZE);
101
+		auto result2 = testSTL(val2, MAX_SIZE);
102
+		if (result1.Value<0>().Compare(result2.Value<0>()))
103
+			DKLogE("Hash Compare: %d (ERROR)", result1.Value<0>().Compare(result2.Value<0>()));
104
+		else
105
+			DKLogI("Hash compare: %d (time: %f)",
106
+				  result1.Value<0>().Compare(result2.Value<0>()),
107
+				  result1.Value<1>() - result2.Value<1>());
101
 	}
108
 	}
102
 	else
109
 	else
103
 	{
110
 	{
104
-		auto hash1 = testSTL(val1, MAX_SIZE);
105
-		auto hash2 = testDK(val2, MAX_SIZE);
106
-		DKLog("Hash compare: %d", hash1.Compare(hash2));
111
+		auto result1 = testDK(val1, MAX_SIZE);
112
+		auto result2 = testSTL(val2, MAX_SIZE);
113
+		if (result1.Value<0>().Compare(result2.Value<0>()))
114
+			DKLogE("Hash Compare: %d (ERROR)", result1.Value<0>().Compare(result2.Value<0>()));
115
+		else
116
+			DKLogI("Hash compare: %d (time: %f)",
117
+				  result1.Value<0>().Compare(result2.Value<0>()),
118
+				  result1.Value<1>() - result2.Value<1>());
107
 	}
119
 	}
108
 
120
 
109
 	delete[] val1;
121
 	delete[] val1;
125
 
137
 
126
 	DoTest<Value64>(true, []()->Value64
138
 	DoTest<Value64>(true, []()->Value64
127
 	{
139
 	{
128
-		Value64 val;
140
+		Value64 val = { 0 };
129
 		val.num = DKRandom();
141
 		val.num = DKRandom();
130
 		return val;
142
 		return val;
131
 	});
143
 	});
132
 	DoTest<Value16>(true, []()->Value16
144
 	DoTest<Value16>(true, []()->Value16
133
 	{
145
 	{
134
-		Value16 val;
146
+		Value16 val = { 0 };
135
 		val.num = DKRandom();
147
 		val.num = DKRandom();
136
 		return val;
148
 		return val;
137
 	});
149
 	});