提交 033b2519 编写于 作者: H Haojun Liao

test: update the unit test cases.

上级 b8753573
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "executor.h" #include "executor.h"
#include "executorimpl.h" #include "executorimpl.h"
#include "function.h" #include "function.h"
#include "stub.h"
#include "taos.h" #include "taos.h"
#include "tdatablock.h" #include "tdatablock.h"
#include "tdef.h" #include "tdef.h"
......
...@@ -26,40 +26,47 @@ ...@@ -26,40 +26,47 @@
TEST(testCase, linear_hash_Tests) { TEST(testCase, linear_hash_Tests) {
taosSeedRand(taosGetTimestampSec()); taosSeedRand(taosGetTimestampSec());
strcpy(tsTempDir, "/tmp/");
_hash_fn_t fn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT); _hash_fn_t fn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT);
#if 0
SLHashObj* pHashObj = tHashInit(256, 4096, fn, 320); int64_t st = taosGetTimestampUs();
for(int32_t i = 0; i < 5000000; ++i) {
SLHashObj* pHashObj = tHashInit(4098*4*2, 512, fn, 40);
for(int32_t i = 0; i < 1000000; ++i) {
int32_t code = tHashPut(pHashObj, &i, sizeof(i), &i, sizeof(i)); int32_t code = tHashPut(pHashObj, &i, sizeof(i), &i, sizeof(i));
assert(code == 0); assert(code == 0);
} }
// tHashPrint(pHashObj, LINEAR_HASH_STATIS); // tHashPrint(pHashObj, LINEAR_HASH_STATIS);
int64_t et = taosGetTimestampUs();
// for(int32_t i = 0; i < 10000; ++i) { for(int32_t i = 0; i < 1000000; ++i) {
// char* v = tHashGet(pHashObj, &i, sizeof(i)); if (i == 950000) {
// if (v != NULL) { printf("kf\n");
//// printf("find value: %d, key:%d\n", *(int32_t*) v, i); }
// } else { char* v = tHashGet(pHashObj, &i, sizeof(i));
if (v != NULL) {
// printf("find value: %d, key:%d\n", *(int32_t*) v, i);
} else {
// printf("failed to found key:%d in hash\n", i); // printf("failed to found key:%d in hash\n", i);
// } }
// } }
tHashPrint(pHashObj, LINEAR_HASH_STATIS); // tHashPrint(pHashObj, LINEAR_HASH_STATIS);
tHashCleanup(pHashObj); tHashCleanup(pHashObj);
#endif int64_t et1 = taosGetTimestampUs();
#if 0 SHashObj* pHashObj1 = taosHashInit(1000, fn, false, HASH_NO_LOCK);
SHashObj* pHashObj = taosHashInit(1000, fn, false, HASH_NO_LOCK);
for(int32_t i = 0; i < 1000000; ++i) { for(int32_t i = 0; i < 1000000; ++i) {
taosHashPut(pHashObj, &i, sizeof(i), &i, sizeof(i)); taosHashPut(pHashObj1, &i, sizeof(i), &i, sizeof(i));
} }
for(int32_t i = 0; i < 10000; ++i) { for(int32_t i = 0; i < 1000000; ++i) {
void* v = taosHashGet(pHashObj, &i, sizeof(i)); void* v = taosHashGet(pHashObj1, &i, sizeof(i));
} }
taosHashCleanup(pHashObj); taosHashCleanup(pHashObj1);
#endif
int64_t et2 = taosGetTimestampUs();
printf("linear hash time:%.2f ms, buildHash:%.2f ms, hash:%.2f\n", (et1-st)/1000.0, (et-st)/1000.0, (et2-et1)/1000.0);
} }
\ No newline at end of file
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "executorimpl.h" #include "executorimpl.h"
#include "executor.h" #include "executor.h"
#include "stub.h"
#include "taos.h" #include "taos.h"
#include "tdatablock.h" #include "tdatablock.h"
#include "tdef.h" #include "tdef.h"
...@@ -196,7 +195,7 @@ int32_t docomp(const void* p1, const void* p2, void* param) { ...@@ -196,7 +195,7 @@ int32_t docomp(const void* p1, const void* p2, void* param) {
} }
} // namespace } // namespace
#if 1 #if 0
TEST(testCase, inMem_sort_Test) { TEST(testCase, inMem_sort_Test) {
SBlockOrderInfo oi = {0}; SBlockOrderInfo oi = {0};
oi.order = TSDB_ORDER_ASC; oi.order = TSDB_ORDER_ASC;
...@@ -382,7 +381,7 @@ TEST(testCase, ordered_merge_sort_Test) { ...@@ -382,7 +381,7 @@ TEST(testCase, ordered_merge_sort_Test) {
} }
void* v = tsortGetValue(pTupleHandle, 0); void* v = tsortGetValue(pTupleHandle, 0);
printf("%d: %d\n", row, *(int32_t*) v); // printf("%d: %d\n", row, *(int32_t*) v);
ASSERT_EQ(row++, *(int32_t*) v); ASSERT_EQ(row++, *(int32_t*) v);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册