Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2bf6b3de
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2bf6b3de
编写于
9月 14, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] update test
上级
a39fbb1f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
21 deletion
+21
-21
src/util/tests/cacheTest.cpp
src/util/tests/cacheTest.cpp
+21
-21
未找到文件。
src/util/tests/cacheTest.cpp
浏览文件 @
2bf6b3de
...
...
@@ -12,65 +12,65 @@ int32_t tsMaxMeterConnections = 200;
// test cache
TEST
(
testCase
,
client_cache_test
)
{
const
int32_t
REFRESH_TIME_IN_SEC
=
2
;
SCacheObj
*
tsc
CacheHandl
e
=
taosCacheInit
(
TSDB_DATA_TYPE_BINARY
,
REFRESH_TIME_IN_SEC
,
0
,
NULL
,
"test"
);
SCacheObj
*
tsc
MetaCach
e
=
taosCacheInit
(
TSDB_DATA_TYPE_BINARY
,
REFRESH_TIME_IN_SEC
,
0
,
NULL
,
"test"
);
const
char
*
key1
=
"test1"
;
char
data1
[]
=
"test11"
;
char
*
cachedObj
=
(
char
*
)
taosCachePut
(
tsc
CacheHandl
e
,
key1
,
strlen
(
key1
),
data1
,
strlen
(
data1
)
+
1
,
1
);
char
*
cachedObj
=
(
char
*
)
taosCachePut
(
tsc
MetaCach
e
,
key1
,
strlen
(
key1
),
data1
,
strlen
(
data1
)
+
1
,
1
);
sleep
(
REFRESH_TIME_IN_SEC
+
1
);
printf
(
"obj is still valid: %s
\n
"
,
cachedObj
);
char
data2
[]
=
"test22"
;
taosCacheRelease
(
tsc
CacheHandl
e
,
(
void
**
)
&
cachedObj
,
false
);
taosCacheRelease
(
tsc
MetaCach
e
,
(
void
**
)
&
cachedObj
,
false
);
/* the object is cleared by cache clean operation */
cachedObj
=
(
char
*
)
taosCachePut
(
tsc
CacheHandl
e
,
key1
,
strlen
(
key1
),
data2
,
strlen
(
data2
)
+
1
,
20
);
cachedObj
=
(
char
*
)
taosCachePut
(
tsc
MetaCach
e
,
key1
,
strlen
(
key1
),
data2
,
strlen
(
data2
)
+
1
,
20
);
printf
(
"after updated: %s
\n
"
,
cachedObj
);
printf
(
"start to remove data from cache
\n
"
);
taosCacheRelease
(
tsc
CacheHandl
e
,
(
void
**
)
&
cachedObj
,
false
);
taosCacheRelease
(
tsc
MetaCach
e
,
(
void
**
)
&
cachedObj
,
false
);
printf
(
"end of removing data from cache
\n
"
);
const
char
*
key3
=
"test2"
;
const
char
*
data3
=
"kkkkkkk"
;
char
*
cachedObj2
=
(
char
*
)
taosCachePut
(
tsc
CacheHandl
e
,
key3
,
strlen
(
key3
),
data3
,
strlen
(
data3
)
+
1
,
1
);
char
*
cachedObj2
=
(
char
*
)
taosCachePut
(
tsc
MetaCach
e
,
key3
,
strlen
(
key3
),
data3
,
strlen
(
data3
)
+
1
,
1
);
printf
(
"%s
\n
"
,
cachedObj2
);
taosCacheRelease
(
tsc
CacheHandl
e
,
(
void
**
)
&
cachedObj2
,
false
);
taosCacheRelease
(
tsc
MetaCach
e
,
(
void
**
)
&
cachedObj2
,
false
);
sleep
(
3
);
char
*
d
=
(
char
*
)
taosCacheAcquireByKey
(
tsc
CacheHandl
e
,
key3
,
strlen
(
key3
));
char
*
d
=
(
char
*
)
taosCacheAcquireByKey
(
tsc
MetaCach
e
,
key3
,
strlen
(
key3
));
// assert(d == NULL);
char
key5
[]
=
"test5"
;
char
data5
[]
=
"data5kkkkk"
;
cachedObj2
=
(
char
*
)
taosCachePut
(
tsc
CacheHandl
e
,
key5
,
strlen
(
key5
),
data5
,
strlen
(
data5
)
+
1
,
20
);
cachedObj2
=
(
char
*
)
taosCachePut
(
tsc
MetaCach
e
,
key5
,
strlen
(
key5
),
data5
,
strlen
(
data5
)
+
1
,
20
);
const
char
*
data6
=
"new Data after updated"
;
taosCacheRelease
(
tsc
CacheHandl
e
,
(
void
**
)
&
cachedObj2
,
false
);
taosCacheRelease
(
tsc
MetaCach
e
,
(
void
**
)
&
cachedObj2
,
false
);
cachedObj2
=
(
char
*
)
taosCachePut
(
tsc
CacheHandl
e
,
key5
,
strlen
(
key5
),
data6
,
strlen
(
data6
)
+
1
,
20
);
cachedObj2
=
(
char
*
)
taosCachePut
(
tsc
MetaCach
e
,
key5
,
strlen
(
key5
),
data6
,
strlen
(
data6
)
+
1
,
20
);
printf
(
"%s
\n
"
,
cachedObj2
);
taosCacheRelease
(
tsc
CacheHandl
e
,
(
void
**
)
&
cachedObj2
,
true
);
taosCacheRelease
(
tsc
MetaCach
e
,
(
void
**
)
&
cachedObj2
,
true
);
const
char
*
data7
=
"add call update procedure"
;
cachedObj2
=
(
char
*
)
taosCachePut
(
tsc
CacheHandl
e
,
key5
,
strlen
(
key5
),
data7
,
strlen
(
data7
)
+
1
,
20
);
cachedObj2
=
(
char
*
)
taosCachePut
(
tsc
MetaCach
e
,
key5
,
strlen
(
key5
),
data7
,
strlen
(
data7
)
+
1
,
20
);
printf
(
"%s
\n
=======================================
\n\n
"
,
cachedObj2
);
char
*
cc
=
(
char
*
)
taosCacheAcquireByKey
(
tsc
CacheHandl
e
,
key5
,
strlen
(
key5
));
char
*
cc
=
(
char
*
)
taosCacheAcquireByKey
(
tsc
MetaCach
e
,
key5
,
strlen
(
key5
));
taosCacheRelease
(
tsc
CacheHandl
e
,
(
void
**
)
&
cachedObj2
,
true
);
taosCacheRelease
(
tsc
CacheHandl
e
,
(
void
**
)
&
cc
,
false
);
taosCacheRelease
(
tsc
MetaCach
e
,
(
void
**
)
&
cachedObj2
,
true
);
taosCacheRelease
(
tsc
MetaCach
e
,
(
void
**
)
&
cc
,
false
);
const
char
*
data8
=
"ttft"
;
const
char
*
key6
=
"key6"
;
char
*
ft
=
(
char
*
)
taosCachePut
(
tsc
CacheHandl
e
,
key6
,
strlen
(
key6
),
data8
,
strlen
(
data8
),
20
);
taosCacheRelease
(
tsc
CacheHandl
e
,
(
void
**
)
&
ft
,
false
);
char
*
ft
=
(
char
*
)
taosCachePut
(
tsc
MetaCach
e
,
key6
,
strlen
(
key6
),
data8
,
strlen
(
data8
),
20
);
taosCacheRelease
(
tsc
MetaCach
e
,
(
void
**
)
&
ft
,
false
);
/**
* 140ns
...
...
@@ -78,14 +78,14 @@ TEST(testCase, client_cache_test) {
uint64_t
startTime
=
taosGetTimestampUs
();
printf
(
"Cache Performance Test
\n
start time:%"
PRIu64
"
\n
"
,
startTime
);
for
(
int32_t
i
=
0
;
i
<
1000
;
++
i
)
{
char
*
dd
=
(
char
*
)
taosCacheAcquireByKey
(
tsc
CacheHandl
e
,
key6
,
strlen
(
key6
));
char
*
dd
=
(
char
*
)
taosCacheAcquireByKey
(
tsc
MetaCach
e
,
key6
,
strlen
(
key6
));
if
(
dd
!=
NULL
)
{
// printf("get the data\n");
}
else
{
printf
(
"data has been released
\n
"
);
}
taosCacheRelease
(
tsc
CacheHandl
e
,
(
void
**
)
&
dd
,
false
);
taosCacheRelease
(
tsc
MetaCach
e
,
(
void
**
)
&
dd
,
false
);
}
uint64_t
endTime
=
taosGetTimestampUs
();
...
...
@@ -93,7 +93,7 @@ TEST(testCase, client_cache_test) {
printf
(
"End of Test, %"
PRIu64
"
\n
Total Elapsed Time:%"
PRIu64
" us.avg:%f us
\n
"
,
endTime
,
el
,
el
/
1000.0
);
taosCacheCleanup
(
tsc
CacheHandl
e
);
taosCacheCleanup
(
tsc
MetaCach
e
);
}
TEST
(
testCase
,
cache_resize_test
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录