Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ee7a18db
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ee7a18db
编写于
9月 08, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: add bench
上级
3acd4d3a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
88 addition
and
11 deletion
+88
-11
source/libs/index/test/CMakeLists.txt
source/libs/index/test/CMakeLists.txt
+27
-5
source/libs/index/test/indexBench.cc
source/libs/index/test/indexBench.cc
+61
-6
未找到文件。
source/libs/index/test/CMakeLists.txt
浏览文件 @
ee7a18db
...
@@ -5,6 +5,7 @@ IF(NOT TD_DARWIN)
...
@@ -5,6 +5,7 @@ IF(NOT TD_DARWIN)
add_executable
(
idxUtilUT
""
)
add_executable
(
idxUtilUT
""
)
add_executable
(
idxJsonUT
""
)
add_executable
(
idxJsonUT
""
)
add_executable
(
idxFstUtilUT
""
)
add_executable
(
idxFstUtilUT
""
)
add_executable
(
idxBench
""
)
target_sources
(
idxTest
target_sources
(
idxTest
PRIVATE
PRIVATE
...
@@ -32,6 +33,10 @@ IF(NOT TD_DARWIN)
...
@@ -32,6 +33,10 @@ IF(NOT TD_DARWIN)
PRIVATE
PRIVATE
"fstUtilUT.cc"
"fstUtilUT.cc"
)
)
target_sources
(
idxBench
PRIVATE
"indexBench.cc"
)
target_include_directories
(
idxTest
target_include_directories
(
idxTest
PUBLIC
PUBLIC
...
@@ -80,6 +85,16 @@ IF(NOT TD_DARWIN)
...
@@ -80,6 +85,16 @@ IF(NOT TD_DARWIN)
"
${
TD_SOURCE_DIR
}
/include/libs/index"
"
${
TD_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
idxJsonUT
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_include_directories
(
idxBench
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_link_libraries
(
idxTest
target_link_libraries
(
idxTest
os
os
...
@@ -102,11 +117,7 @@ IF(NOT TD_DARWIN)
...
@@ -102,11 +117,7 @@ IF(NOT TD_DARWIN)
gtest_main
gtest_main
index
index
)
)
target_include_directories
(
idxJsonUT
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_link_libraries
(
idxTest
target_link_libraries
(
idxTest
os
os
util
util
...
@@ -151,6 +162,13 @@ IF(NOT TD_DARWIN)
...
@@ -151,6 +162,13 @@ IF(NOT TD_DARWIN)
gtest_main
gtest_main
index
index
)
)
target_link_libraries
(
idxBench
os
util
common
gtest_main
index
)
add_test
(
add_test
(
NAME idxJsonUT
NAME idxJsonUT
...
@@ -174,4 +192,8 @@ IF(NOT TD_DARWIN)
...
@@ -174,4 +192,8 @@ IF(NOT TD_DARWIN)
NAME idxFstUT
NAME idxFstUT
COMMAND idxFstUT
COMMAND idxFstUT
)
)
add_test
(
NAME idxBench
COMMAND idxBench
)
ENDIF
()
ENDIF
()
source/libs/index/test/indexBench.cc
浏览文件 @
ee7a18db
...
@@ -18,8 +18,18 @@
...
@@ -18,8 +18,18 @@
#include <string>
#include <string>
#include <thread>
#include <thread>
#include "index.h"
#include "index.h"
#include "indexCache.h"
#include "indexFst.h"
#include "indexFstUtil.h"
#include "indexInt.h"
#include "indexTfile.h"
#include "indexUtil.h"
#include "tskiplist.h"
#include "tutil.h"
using
namespace
std
;
using
namespace
std
;
static
std
::
string
logDir
=
TD_TMP_DIR_PATH
"log"
;
static
void
initLog
()
{
static
void
initLog
()
{
const
char
*
defaultLogFileNamePrefix
=
"taoslog"
;
const
char
*
defaultLogFileNamePrefix
=
"taoslog"
;
const
int32_t
maxLogFileNum
=
10
;
const
int32_t
maxLogFileNum
=
10
;
...
@@ -42,18 +52,20 @@ class Idx {
...
@@ -42,18 +52,20 @@ class Idx {
public:
public:
Idx
(
int
_cacheSize
=
1024
*
1024
*
4
,
const
char
*
_path
=
"tindex"
)
{
Idx
(
int
_cacheSize
=
1024
*
1024
*
4
,
const
char
*
_path
=
"tindex"
)
{
opts
.
cacheSize
=
_cacheSize
;
opts
.
cacheSize
=
_cacheSize
;
path
=
TD_TMP_DIR_PATH
_path
;
path
+=
TD_TMP_DIR_PATH
;
path
+=
_path
;
}
}
int
SetUp
(
bool
remove
)
{
int
SetUp
(
bool
remove
)
{
initLog
();
initLog
();
if
(
remove
)
taosRemoveDir
(
path
);
if
(
remove
)
taosRemoveDir
(
path
.
c_str
()
);
int
ret
=
indexJsonOpen
(
&
opts
,
path
,
&
index
);
int
ret
=
indexJsonOpen
(
&
opts
,
path
.
c_str
()
,
&
index
);
return
ret
;
return
ret
;
}
}
int
Write
(
WriteBatch
*
batch
)
{
int
Write
(
WriteBatch
*
batch
,
uint64_t
uid
)
{
// write batch
// write batch
indexJsonPut
(
index
,
batch
->
terms
,
uid
);
return
0
;
return
0
;
}
}
int
Read
(
const
char
*
json
,
void
*
key
,
int64_t
*
id
)
{
int
Read
(
const
char
*
json
,
void
*
key
,
int64_t
*
id
)
{
...
@@ -69,7 +81,49 @@ class Idx {
...
@@ -69,7 +81,49 @@ class Idx {
SIndex
*
index
;
SIndex
*
index
;
};
};
int
BenchWrite
(
Idx
*
idx
,
int
nCol
,
int
Limit
)
{
return
0
;
}
SIndexTerm
*
indexTermCreateT
(
int64_t
suid
,
SIndexOperOnColumn
oper
,
uint8_t
colType
,
const
char
*
colName
,
int32_t
nColName
,
const
char
*
colVal
,
int32_t
nColVal
)
{
char
buf
[
256
]
=
{
0
};
int16_t
sz
=
nColVal
;
memcpy
(
buf
,
(
uint16_t
*
)
&
sz
,
2
);
memcpy
(
buf
+
2
,
colVal
,
nColVal
);
if
(
colType
==
TSDB_DATA_TYPE_BINARY
)
{
return
indexTermCreate
(
suid
,
oper
,
colType
,
colName
,
nColName
,
buf
,
sizeof
(
buf
));
}
else
{
return
indexTermCreate
(
suid
,
oper
,
colType
,
colName
,
nColName
,
colVal
,
nColVal
);
}
return
NULL
;
}
int
initWriteBatch
(
WriteBatch
*
wb
,
int
batchSize
)
{
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
std
::
string
colName
;
std
::
string
colVal
;
for
(
int
i
=
0
;
i
<
64
;
i
++
)
{
colName
+=
'0'
+
i
;
colVal
+=
'0'
+
i
;
}
for
(
int
i
=
0
;
i
<
batchSize
;
i
++
)
{
colVal
[
i
%
colVal
.
size
()]
=
'0'
+
i
%
128
;
colName
[
i
%
colName
.
size
()]
=
'0'
+
i
%
128
;
SIndexTerm
*
term
=
indexTermCreateT
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
indexMultiTermAdd
(
terms
,
term
);
}
wb
->
terms
=
terms
;
return
0
;
}
int
BenchWrite
(
Idx
*
idx
,
int
batchSize
,
int
limit
)
{
for
(
int
i
=
0
;
i
<
limit
;
i
+=
batchSize
)
{
WriteBatch
wb
;
idx
->
Write
(
&
wb
,
i
);
}
return
0
;
}
int
BenchRead
(
Idx
*
idx
)
{
return
0
;
}
int
BenchRead
(
Idx
*
idx
)
{
return
0
;
}
...
@@ -81,5 +135,6 @@ int main() {
...
@@ -81,5 +135,6 @@ int main() {
}
else
{
}
else
{
std
::
cout
<<
"succ to setup index"
<<
std
::
endl
;
std
::
cout
<<
"succ to setup index"
<<
std
::
endl
;
}
}
BenchWrite
(
idx
,
10000
,
100
);
BenchWrite
(
idx
,
100
,
10000
);
return
1
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录