2014-11-19 00:25:21 +08:00
|
|
|
|
// session.cpp : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨Ӧ<CCA8>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ㡣
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
2015-06-03 11:19:13 +08:00
|
|
|
|
#include "session.h"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2015-06-03 11:19:13 +08:00
|
|
|
|
static void usage(const char* procname)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
{
|
2015-06-03 11:19:13 +08:00
|
|
|
|
printf("usage: %s -h [help]\r\n"
|
|
|
|
|
"-s server_addr\r\n"
|
|
|
|
|
"-n count\r\n"
|
|
|
|
|
"-c max_threads\r\n"
|
|
|
|
|
"-a action[memcache|memcache_delay|redis]\r\n", procname);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-03 11:19:13 +08:00
|
|
|
|
int main(int argc, char* argv[])
|
2014-11-19 00:25:21 +08:00
|
|
|
|
{
|
2015-06-03 11:19:13 +08:00
|
|
|
|
char addr[256], action[32];
|
|
|
|
|
int nloop = 10, ch, max_threads = 1;
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2015-06-03 11:19:13 +08:00
|
|
|
|
acl::acl_cpp_init();
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2015-06-03 11:19:13 +08:00
|
|
|
|
acl::safe_snprintf(action, sizeof(action), "redis");
|
|
|
|
|
acl::safe_snprintf(addr, sizeof(addr), "192.168.0.250:11211");
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2015-06-03 11:19:13 +08:00
|
|
|
|
while ((ch = getopt(argc, argv, "hs:n:c:a:")) > 0)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
{
|
2015-06-03 11:19:13 +08:00
|
|
|
|
switch (ch)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
{
|
2015-06-03 11:19:13 +08:00
|
|
|
|
case 'h':
|
|
|
|
|
usage(argv[0]);
|
|
|
|
|
return 0;
|
|
|
|
|
case 's':
|
|
|
|
|
acl::safe_snprintf(addr, sizeof(addr), "%s", optarg);
|
|
|
|
|
break;
|
|
|
|
|
case 'n':
|
|
|
|
|
nloop = atoi(optarg);
|
|
|
|
|
if (nloop <= 0)
|
|
|
|
|
nloop = 10;
|
|
|
|
|
break;
|
|
|
|
|
case 'c':
|
|
|
|
|
max_threads = atoi(optarg);
|
|
|
|
|
break;
|
|
|
|
|
case 'a':
|
|
|
|
|
acl::safe_snprintf(action, sizeof(action), "%s", optarg);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2014-11-19 00:25:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-03 11:19:13 +08:00
|
|
|
|
printf("nloop: %d, max_threads: %d\r\n", nloop, max_threads);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2015-06-03 11:19:13 +08:00
|
|
|
|
if (strcasecmp(action, "memcache") == 0)
|
|
|
|
|
test_memcache_session(addr, nloop);
|
|
|
|
|
else if (strcasecmp(action, "memcache_delay") == 0)
|
|
|
|
|
test_memcache_session_delay(addr);
|
|
|
|
|
else if (strcasecmp(action, "redis") == 0)
|
|
|
|
|
test_redis_session(addr, nloop, max_threads);
|
|
|
|
|
else if (strcasecmp(action, "redis_attrs") == 0)
|
|
|
|
|
test_redis_session_attrs(addr, nloop);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
else
|
2015-06-03 11:19:13 +08:00
|
|
|
|
printf("unknown action: %s\r\n", action);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
printf("enter any key to exit\r\n");
|
|
|
|
|
getchar();
|
|
|
|
|
#endif
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|