Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
14d24a3e
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
14d24a3e
编写于
1月 12, 2016
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dbms: benchmark: added randomization option [#METR-2944].
上级
d7cc44ff
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
1 deletion
+24
-1
dbms/src/Client/Benchmark.cpp
dbms/src/Client/Benchmark.cpp
+24
-1
未找到文件。
dbms/src/Client/Benchmark.cpp
浏览文件 @
14d24a3e
...
...
@@ -2,10 +2,12 @@
#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <random>
#include <Poco/File.h>
#include <Poco/SharedPtr.h>
...
...
@@ -45,15 +47,24 @@
namespace
DB
{
namespace
ErrorCodes
{
extern
const
int
POCO_EXCEPTION
;
extern
const
int
STD_EXCEPTION
;
extern
const
int
UNKNOWN_EXCEPTION
;
}
class
Benchmark
{
public:
Benchmark
(
unsigned
concurrency_
,
double
delay_
,
const
String
&
host_
,
UInt16
port_
,
const
String
&
default_database_
,
const
String
&
user_
,
const
String
&
password_
,
const
String
&
stage
,
bool
randomize_
,
const
Settings
&
settings_
)
:
concurrency
(
concurrency_
),
delay
(
delay_
),
queue
(
concurrency
),
connections
(
concurrency
,
host_
,
port_
,
default_database_
,
user_
,
password_
),
randomize
(
randomize_
),
settings
(
settings_
),
pool
(
concurrency
)
{
std
::
cerr
<<
std
::
fixed
<<
std
::
setprecision
(
3
);
...
...
@@ -84,6 +95,7 @@ private:
Queue
queue
;
ConnectionPool
connections
;
bool
randomize
;
Settings
settings
;
QueryProcessingStage
::
Enum
query_processing_stage
;
...
...
@@ -161,6 +173,11 @@ private:
void
run
()
{
timespec
current_clock
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
current_clock
);
std
::
mt19937
generator
(
current_clock
.
tv_nsec
);
std
::
uniform_int_distribution
<
size_t
>
distribution
(
0
,
queries
.
size
()
-
1
);
for
(
size_t
i
=
0
;
i
<
concurrency
;
++
i
)
pool
.
schedule
(
std
::
bind
(
&
Benchmark
::
thread
,
this
,
connections
.
IConnectionPool
::
get
()));
...
...
@@ -175,7 +192,11 @@ private:
if
(
i
>=
queries
.
size
())
i
=
0
;
queue
.
push
(
queries
[
i
]);
size_t
query_index
=
randomize
?
distribution
(
generator
)
:
i
;
queue
.
push
(
queries
[
query_index
]);
if
(
watch
.
elapsedSeconds
()
>
delay
)
{
...
...
@@ -336,6 +357,7 @@ int main(int argc, char ** argv)
(
"password"
,
boost
::
program_options
::
value
<
std
::
string
>
()
->
default_value
(
""
),
""
)
(
"database"
,
boost
::
program_options
::
value
<
std
::
string
>
()
->
default_value
(
"default"
),
""
)
(
"stage"
,
boost
::
program_options
::
value
<
std
::
string
>
()
->
default_value
(
"complete"
),
"request query processing up to specified stage"
)
(
"randomize,r"
,
boost
::
program_options
::
value
<
bool
>
()
->
default_value
(
false
),
"randomize order of execution"
)
#define DECLARE_SETTING(TYPE, NAME, DEFAULT) (#NAME, boost::program_options::value<std::string> (), "Settings.h")
#define DECLARE_LIMIT(TYPE, NAME, DEFAULT) (#NAME, boost::program_options::value<std::string> (), "Limits.h")
APPLY_FOR_SETTINGS
(
DECLARE_SETTING
)
...
...
@@ -373,6 +395,7 @@ int main(int argc, char ** argv)
options
[
"user"
].
as
<
std
::
string
>
(),
options
[
"password"
].
as
<
std
::
string
>
(),
options
[
"stage"
].
as
<
std
::
string
>
(),
options
[
"randomize"
].
as
<
bool
>
(),
settings
);
}
catch
(
const
Exception
&
e
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录