1#pragma once
2
3#include <Client/Connection.h>
4#include <Common/InterruptListener.h>
5#include <common/logger_useful.h>
6#include <Poco/Util/XMLConfiguration.h>
7
8#include <IO/ConnectionTimeouts.h>
9#include "PerformanceTestInfo.h"
10
11namespace DB
12{
13
14using XMLConfiguration = Poco::Util::XMLConfiguration;
15using XMLConfigurationPtr = Poco::AutoPtr<XMLConfiguration>;
16using QueriesWithIndexes = std::vector<std::pair<std::string, size_t>>;
17
18class PerformanceTest
19{
20public:
21 PerformanceTest(
22 const XMLConfigurationPtr & config_,
23 Connection & connection_,
24 const ConnectionTimeouts & timeouts_,
25 InterruptListener & interrupt_listener_,
26 const PerformanceTestInfo & test_info_,
27 Context & context_,
28 const std::vector<size_t> & queries_to_run_);
29
30 bool checkPreconditions() const;
31 void prepare() const;
32 std::vector<TestStats> execute();
33 void finish() const;
34
35 bool checkSIGINT() const
36 {
37 return got_SIGINT;
38 }
39
40private:
41 void runQueries(
42 const QueriesWithIndexes & queries_with_indexes,
43 std::vector<TestStats> & statistics_by_run);
44
45 UInt64 calculateMaxExecTime() const;
46
47private:
48 XMLConfigurationPtr config;
49 Connection & connection;
50 const ConnectionTimeouts & timeouts;
51 InterruptListener & interrupt_listener;
52
53 PerformanceTestInfo test_info;
54 Context & context;
55
56 std::vector<size_t> queries_to_run;
57 Poco::Logger * log;
58
59 bool got_SIGINT = false;
60};
61
62}
63