Browse Source

no message

Hongtae Kim 6 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
 #include <algorithm>
8
 #include <algorithm>
9
 #include <DK.h>
9
 #include <DK.h>
10
 
10
 
11
-#define MAX_SIZE 100000000ULL
11
+
12
+#define MAX_SIZE 200000000ULL
12
 
13
 
13
 #ifdef _WIN32
14
 #ifdef _WIN32
14
 int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
15
 int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
28
 		} i32;
29
 		} i32;
29
 	};
30
 	};
30
 
31
 
31
-
32
-
33
 	auto testStd = [](Value* val_copy, const Value* input, size_t len)->DKHashResultSHA1
32
 	auto testStd = [](Value* val_copy, const Value* input, size_t len)->DKHashResultSHA1
34
 	{
33
 	{
35
 		DKLogI("Copying buffer...");
34
 		DKLogI("Copying buffer...");
36
 		memcpy(val_copy, input, sizeof(Value) * len);
35
 		memcpy(val_copy, input, sizeof(Value) * len);
37
 
36
 
38
 		DKTimer timer;
37
 		DKTimer timer;
38
+		DKThread::Sleep(1.0);
39
 		DKLogI("Sorting by std::sort...");
39
 		DKLogI("Sorting by std::sort...");
40
 		timer.Reset();
40
 		timer.Reset();
41
 		std::sort(val_copy, val_copy + MAX_SIZE, [](const Value& lhs, const Value& rhs)->bool
41
 		std::sort(val_copy, val_copy + MAX_SIZE, [](const Value& lhs, const Value& rhs)->bool
44
 		});
44
 		});
45
 		double e1 = timer.Elapsed();
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
 		return DKHashSHA1(val_copy, sizeof(Value)*len);
50
 		return DKHashSHA1(val_copy, sizeof(Value)*len);
49
 	};
51
 	};
50
 	auto testDK = [](Value* val_copy, const Value* input, size_t len)->DKHashResultSHA1
52
 	auto testDK = [](Value* val_copy, const Value* input, size_t len)->DKHashResultSHA1
55
 		DKStaticArray<Value> tmp(val_copy, MAX_SIZE);
57
 		DKStaticArray<Value> tmp(val_copy, MAX_SIZE);
56
 
58
 
57
 		DKTimer timer;
59
 		DKTimer timer;
60
+		DKThread::Sleep(1.0);
58
 		DKLogI("Sorting by DKStaticArray::Sort...");
61
 		DKLogI("Sorting by DKStaticArray::Sort...");
59
 		timer.Reset();
62
 		timer.Reset();
60
 		tmp.Sort([](const Value& lhs, const Value& rhs)->bool
63
 		tmp.Sort([](const Value& lhs, const Value& rhs)->bool
63
 		});
66
 		});
64
 		double e1 = timer.Elapsed();
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
 		return DKHashSHA1(val_copy, sizeof(Value)*len);
72
 		return DKHashSHA1(val_copy, sizeof(Value)*len);
68
 	};
73
 	};
69
 
74
 
70
 	DKApplication app;
75
 	DKApplication app;
71
-	DKLog("Allocating buffer...");
72
-
73
 	Value* val1 = new Value[MAX_SIZE];
76
 	Value* val1 = new Value[MAX_SIZE];
74
 
77
 
78
+	DKLog("Generating data...1");
75
 	for (size_t i = 0; i < MAX_SIZE; ++i)
79
 	for (size_t i = 0; i < MAX_SIZE; ++i)
76
 	{
80
 	{
77
 		val1[i].i32 = { DKRandom(), DKRandom() };
81
 		val1[i].i32 = { DKRandom(), DKRandom() };
78
 	}
82
 	}
79
 	Value* val_copy = new Value[MAX_SIZE];
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
 	delete[] val1;
102
 	delete[] val1;
88
 	delete[] val_copy;
103
 	delete[] val_copy;

+ 0
- 1
TestApp1/dkgl_new.cpp View File

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