test: update the unit test cases.

This commit is contained in:
Haojun Liao 2022-08-24 18:48:03 +08:00
parent b87535734f
commit 033b251994
3 changed files with 33 additions and 28 deletions

View File

@ -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"

View File

@ -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) {
// 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);
// }
// }
tHashPrint(pHashObj, LINEAR_HASH_STATIS);
tHashCleanup(pHashObj);
#endif
#if 0
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)); if (i == 950000) {
printf("kf\n");
}
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);
}
} }
for(int32_t i = 0; i < 10000; ++i) { // tHashPrint(pHashObj, LINEAR_HASH_STATIS);
void* v = taosHashGet(pHashObj, &i, sizeof(i)); tHashCleanup(pHashObj);
} int64_t et1 = taosGetTimestampUs();
taosHashCleanup(pHashObj);
#endif
SHashObj* pHashObj1 = taosHashInit(1000, fn, false, HASH_NO_LOCK);
for(int32_t i = 0; i < 1000000; ++i) {
taosHashPut(pHashObj1, &i, sizeof(i), &i, sizeof(i));
}
for(int32_t i = 0; i < 1000000; ++i) {
void* v = taosHashGet(pHashObj1, &i, sizeof(i));
}
taosHashCleanup(pHashObj1);
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);
} }

View File

@ -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) {
} }
} // 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) {
} }
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);
} }