MCPcopy Create free account
hub / github.com/DeNA/HandlerSocket-Plugin-for-MySQL / hstest_main

Function hstest_main

client/hstest.cpp:1446–1523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1444}
1445
1446int
1447hstest_main(int argc, char **argv)
1448{
1449 ignore_sigpipe();
1450 hstest_shared shared;
1451 parse_args(argc, argv, shared.conf);
1452 shared.conf["port"] = shared.conf["hsport"];
1453 shared.arg.set(shared.conf);
1454 shared.loop = shared.conf.get_int("num", 1000);
1455 shared.pipe = shared.conf.get_int("pipe", 1);
1456 shared.verbose = shared.conf.get_int("verbose", 1);
1457 const int tablesize = shared.conf.get_int("tablesize", 0);
1458 std::vector<char> keygen(tablesize);
1459 shared.keygen = &keygen[0];
1460 shared.keygen_size = tablesize;
1461 shared.usleep = shared.conf.get_int("usleep", 0);
1462 shared.dump = shared.conf.get_int("dump", 0);
1463 shared.num_threads = shared.conf.get_int("num_threads", 10);
1464 shared.wait_conn = shared.conf.get_int("wait_conn", 0);
1465 const std::string op = shared.conf.get_str("op", "G");
1466 if (op.size() > 0) {
1467 shared.op = op[0];
1468 }
1469 #if 0
1470 const int localdb_flag = shared.conf.get_int("local", 0);
1471 if (localdb_flag) {
1472 shared.localdb = database_i::create(shared.conf);
1473 }
1474 #endif
1475 const int num_thrs = shared.num_threads;
1476 typedef thread<hstest_thread> thread_type;
1477 typedef std::auto_ptr<thread_type> thread_ptr;
1478 typedef auto_ptrcontainer< std::vector<thread_type *> > thrs_type;
1479 thrs_type thrs;
1480 for (int i = 0; i < num_thrs; ++i) {
1481 const hstest_thread::arg_type arg(i, shared, false);
1482 thread_ptr thr(new thread<hstest_thread>(arg));
1483 thrs.push_back_ptr(thr);
1484 }
1485 for (size_t i = 0; i < thrs.size(); ++i) {
1486 thrs[i]->start();
1487 }
1488 thread_ptr watch_thread;
1489 const int timelimit = shared.conf.get_int("timelimit", 0);
1490 {
1491 const hstest_thread::arg_type arg(0, shared, true);
1492 watch_thread = thread_ptr(new thread<hstest_thread>(arg));
1493 watch_thread->start();
1494 }
1495 size_t iocnt = 0, opcnt = 0;
1496 double respmin = 999999, respmax = 0;
1497 double respsum = 0;
1498 if (timelimit != 0) {
1499 watch_thread->join();
1500 }
1501 for (size_t i = 0; i < thrs.size(); ++i) {
1502 if (timelimit == 0) {
1503 thrs[i]->join();

Callers 1

mainFunction · 0.85

Calls 9

ignore_sigpipeFunction · 0.85
parse_argsFunction · 0.85
setMethod · 0.80
get_intMethod · 0.80
get_strMethod · 0.80
push_back_ptrMethod · 0.80
sizeMethod · 0.45
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected