-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathttbenchmark.cpp
74 lines (53 loc) · 2.07 KB
/
ttbenchmark.cpp
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
71
72
73
74
/*
* ttbenchmark.cpp
*
* Created on: 2014-12-14
* Author: liguangyu
*/
#include "netlib.h"
#include "ConfigFileReader.h"
#include "version.h"
#include "MsgServInfo.h"
#include "ClientConn.h"
uint32_t g_msg_server_count = 0;
msg_serv_info_t* g_msg_server_list=0;
int main(int argc, char* argv[])
{
if ((argc == 2) && (strcmp(argv[1], "-v") == 0)) {
printf("client Version: ttbenchmark/%s\n", VERSION);
printf("client Build: %s %s\n", __DATE__, __TIME__);
printf("usage \"ttbenchmark -sql >user.sql\" to create user.sql\nmysql -u$USER -p$PASSWORD < user.sql\n");
return 0;
}
CConfigFileReader config_file("ttbenchmark.conf");
g_msg_server_count = 0;
g_msg_server_list = read_msg_server_config(&config_file, "MsgServerIP", "MsgServerPort",
"MsgServerConnNum","MsgServerUserName","MsgServerPwd",g_msg_server_count);
log("ttbenchmark.conf has : %d msg servers\n", g_msg_server_count);
if(g_msg_server_count<=0)
return 0;
if ((argc == 2) && (strcmp(argv[1], "-sql") == 0)) {
//INSERT INTO `IMUsers` VALUES ('10004', 'mykeyonline', 'wenyuangui', 'e10adc3949ba59abbe56e057f20f883e', '0', 'g0/000/000/1417614097916119_140360801912.jpg', 'ÎÄÔ¶¹ï', '1010', '1', 'ÉîÛÚ', '13911111111', '[email protected]', '1', '1', '1409816664');
printf("use macim;\n");
for(int i=0;i<g_msg_server_list[0].num_connection;i++)
{
printf("INSERT INTO `IMUsers` VALUES ('%d', 'mykeyonline', '%s%d', '%s', '0', 'g0/000/000/1417614097916119_140360801912.jpg',\
'name%s%d', '1010', '1', 'ÉîÛÚ', '13911111111', '[email protected]', '1', '1', '1409816664'); \n",
i+g_msg_server_list[0].nUserIDStart,g_msg_server_list[0].szUserName,i,g_msg_server_list[0].szPassword,g_msg_server_list[0].szUserName,i);
}
return 0;
}
signal(SIGPIPE, SIG_IGN);
srand(time(NULL));
log("ttbenchmark max files can open: %d\n", getdtablesize());
int ret = netlib_init();
if (ret == NETLIB_ERROR)
{
printf("netlib_init error!");
return ret;
}
init_msg_serv_conn(g_msg_server_list, g_msg_server_count);
printf("now enter the event loop...\n");
netlib_eventloop();
return 0;
}