Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f8f60c45
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
f8f60c45
编写于
4年前
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-822] update the test script.
上级
d616e0f1
无相关合并请求
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
14 deletion
+14
-14
src/util/tests/cacheTest.cpp
src/util/tests/cacheTest.cpp
+14
-14
未找到文件。
src/util/tests/cacheTest.cpp
浏览文件 @
f8f60c45
...
...
@@ -19,12 +19,12 @@ int32_t tsMaxMeterConnections = 200;
// test cache
TEST
(
testCase
,
client_cache_test
)
{
const
int32_t
REFRESH_TIME_IN_SEC
=
2
;
SCacheObj
*
tscCacheHandle
=
taosCacheInit
(
REFRESH_TIME_IN_SEC
);
SCacheObj
*
tscCacheHandle
=
taosCacheInit
(
TSDB_DATA_TYPE_BINARY
,
REFRESH_TIME_IN_SEC
,
0
,
NULL
);
const
char
*
key1
=
"test1"
;
char
data1
[]
=
"test11"
;
char
*
cachedObj
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key1
,
data1
,
strlen
(
data1
)
+
1
,
1
);
char
*
cachedObj
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key1
,
strlen
(
key1
),
data1
,
strlen
(
data1
)
+
1
,
1
);
sleep
(
REFRESH_TIME_IN_SEC
+
1
);
printf
(
"obj is still valid: %s
\n
"
,
cachedObj
);
...
...
@@ -33,7 +33,7 @@ TEST(testCase, client_cache_test) {
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
cachedObj
,
false
);
/* the object is cleared by cache clean operation */
cachedObj
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key1
,
data2
,
strlen
(
data2
)
+
1
,
20
);
cachedObj
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key1
,
strlen
(
key1
),
data2
,
strlen
(
data2
)
+
1
,
20
);
printf
(
"after updated: %s
\n
"
,
cachedObj
);
printf
(
"start to remove data from cache
\n
"
);
...
...
@@ -43,32 +43,32 @@ TEST(testCase, client_cache_test) {
const
char
*
key3
=
"test2"
;
const
char
*
data3
=
"kkkkkkk"
;
char
*
cachedObj2
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key3
,
data3
,
strlen
(
data3
)
+
1
,
1
);
char
*
cachedObj2
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key3
,
strlen
(
key3
),
data3
,
strlen
(
data3
)
+
1
,
1
);
printf
(
"%s
\n
"
,
cachedObj2
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
cachedObj2
,
false
);
sleep
(
3
);
char
*
d
=
(
char
*
)
taosCacheAcquireBy
Name
(
tscCacheHandle
,
key3
);
char
*
d
=
(
char
*
)
taosCacheAcquireBy
Key
(
tscCacheHandle
,
key3
,
strlen
(
key3
)
);
// assert(d == NULL);
char
key5
[]
=
"test5"
;
char
data5
[]
=
"data5kkkkk"
;
cachedObj2
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key5
,
data5
,
strlen
(
data5
)
+
1
,
20
);
cachedObj2
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key5
,
strlen
(
key5
),
data5
,
strlen
(
data5
)
+
1
,
20
);
const
char
*
data6
=
"new Data after updated"
;
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
cachedObj2
,
false
);
cachedObj2
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key5
,
data6
,
strlen
(
data6
)
+
1
,
20
);
cachedObj2
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key5
,
strlen
(
key5
),
data6
,
strlen
(
data6
)
+
1
,
20
);
printf
(
"%s
\n
"
,
cachedObj2
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
cachedObj2
,
true
);
const
char
*
data7
=
"add call update procedure"
;
cachedObj2
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key5
,
data7
,
strlen
(
data7
)
+
1
,
20
);
cachedObj2
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key5
,
strlen
(
key5
),
data7
,
strlen
(
data7
)
+
1
,
20
);
printf
(
"%s
\n
=======================================
\n\n
"
,
cachedObj2
);
char
*
cc
=
(
char
*
)
taosCacheAcquireBy
Name
(
tscCacheHandle
,
key5
);
char
*
cc
=
(
char
*
)
taosCacheAcquireBy
Key
(
tscCacheHandle
,
key5
,
strlen
(
key5
)
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
cachedObj2
,
true
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
cc
,
false
);
...
...
@@ -76,7 +76,7 @@ TEST(testCase, client_cache_test) {
const
char
*
data8
=
"ttft"
;
const
char
*
key6
=
"key6"
;
char
*
ft
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key6
,
data8
,
strlen
(
data8
),
20
);
char
*
ft
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key6
,
strlen
(
key6
),
data8
,
strlen
(
data8
),
20
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
ft
,
false
);
/**
...
...
@@ -85,7 +85,7 @@ 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
*
)
taosCacheAcquireBy
Name
(
tscCacheHandle
,
key6
);
char
*
dd
=
(
char
*
)
taosCacheAcquireBy
Key
(
tscCacheHandle
,
key6
,
strlen
(
key6
)
);
if
(
dd
!=
NULL
)
{
// printf("get the data\n");
}
else
{
...
...
@@ -105,7 +105,7 @@ TEST(testCase, client_cache_test) {
TEST
(
testCase
,
cache_resize_test
)
{
const
int32_t
REFRESH_TIME_IN_SEC
=
2
;
auto
*
pCache
=
taosCacheInit
(
REFRESH_TIME_IN_SEC
);
auto
*
pCache
=
taosCacheInit
(
TSDB_DATA_TYPE_BINARY
,
REFRESH_TIME_IN_SEC
,
false
,
NULL
);
char
key
[
256
]
=
{
0
};
char
data
[
1024
]
=
"abcdefghijk"
;
...
...
@@ -116,7 +116,7 @@ TEST(testCase, cache_resize_test) {
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
len
=
sprintf
(
key
,
"abc_%7d"
,
i
);
taosCachePut
(
pCache
,
key
,
data
,
len
,
3600
);
taosCachePut
(
pCache
,
key
,
strlen
(
key
),
data
,
len
,
3600
);
}
uint64_t
endTime
=
taosGetTimestampUs
();
...
...
@@ -125,7 +125,7 @@ TEST(testCase, cache_resize_test) {
startTime
=
taosGetTimestampUs
();
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
len
=
sprintf
(
key
,
"abc_%7d"
,
i
);
void
*
k
=
taosCacheAcquireBy
Name
(
pCache
,
key
);
void
*
k
=
taosCacheAcquireBy
Key
(
pCache
,
key
,
len
);
assert
(
k
!=
0
);
}
endTime
=
taosGetTimestampUs
();
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
反馈
建议
客服
返回
顶部