-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.cc
70 lines (63 loc) · 1.38 KB
/
main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <iostream>
#include "client.h"
#include "run_test.h"
using namespace std;
extern size_t thread_cnt;
extern size_t table_cnt;
extern size_t row_cnt;
void usage() {
printf("usage: $main input_file_name");
/*printf("usage: $main [thread_cnt] [table_cnt] [row_cnt]\n");
printf("\tthread_cnt [1, 100], default 1\n");
printf("\table_cnt [1, 1000], default 100\n");
printf("\trow_cnt [100, 10M], default 1000\n");
*/
exit(-1);
}
bool parse_args(int argc, char* argv[]) {
if (argc > 4) {
usage();
return false;
}
for (int i = 1; i < argc; i++) {
if (i == 1) {
thread_cnt = stol(argv[1]);
if (thread_cnt == 0 || thread_cnt > 100) {
usage();
return false;
}
}
if (i == 2) {
table_cnt = stol(argv[2]);
if (table_cnt == 0 || table_cnt > 1000) {
usage();
return false;
}
}
if (i == 3) {
row_cnt = stol(argv[3]);
if (row_cnt == 0 || row_cnt < 100 || row_cnt > 10 * 1000 * 1000) {
usage();
return false;
}
}
}
return true;
}
int main(int argc, char* argv[]) {
printf("start time %lld\n", time(0));
printf("start connecting...\n");
Mysql client;
if (!client.connect()) {
printf("conn failed\n");
return -1;
}
printf("conn succ\n");
string input;
if (argc == 2) {
input = argv[1];
}
Init(input);
StartStress();
return 0;
}