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

Method test_watch

client/hstest.cpp:1092–1179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1090}
1091
1092void
1093hstest_thread::test_watch()
1094{
1095 const int timelimit = arg.sh.conf.get_int("timelimit", 0);
1096 const int timelimit_offset = timelimit / 2;
1097 int loop = 0;
1098 double t1 = 0, t2 = 0;
1099 size_t cnt_t1 = 0, cnt_t2 = 0;
1100 size_t prev_cnt = 0;
1101 double now_f = 0;
1102 while (true) {
1103 sleep(1);
1104 const size_t cnt = arg.sh.count;
1105 const size_t df = cnt - prev_cnt;
1106 prev_cnt = cnt;
1107 const double now_prev = now_f;
1108 now_f = gettimeofday_double();
1109 if (now_prev != 0) {
1110 const double rps = static_cast<double>(df) / (now_f - now_prev);
1111 fprintf(stderr, "now: %zu cntdiff: %zu tdiff: %f rps: %f\n",
1112 static_cast<size_t>(now_f), df, now_f - now_prev, rps);
1113 }
1114 if (timelimit != 0) {
1115 if (arg.sh.wait_conn == 0 || arg.sh.conn_count >= arg.sh.wait_conn) {
1116 ++loop;
1117 }
1118 if (loop == timelimit_offset) {
1119 t1 = gettimeofday_double();
1120 cnt_t1 = cnt;
1121 arg.sh.enable_timing = 1;
1122 fprintf(stderr, "start timing\n");
1123 } else if (loop == timelimit_offset + timelimit) {
1124 t2 = gettimeofday_double();
1125 cnt_t2 = cnt;
1126 const size_t cnt_diff = cnt_t2 - cnt_t1;
1127 const double tdiff = t2 - t1;
1128 const double qps = cnt_diff / (tdiff != 0 ? tdiff : 1);
1129 fprintf(stderr, "(%f: %zu, %f: %zu), %10.5f qps\n",
1130 t1, cnt_t1, t2, cnt_t2, qps);
1131 size_t keycnt = 0;
1132 for (int i = 0; i < arg.sh.keygen_size; ++i) {
1133 if (arg.sh.keygen[i]) {
1134 ++keycnt;
1135 }
1136 }
1137 fprintf(stderr, "keygen=%zu\n", keycnt);
1138 break;
1139 }
1140 }
1141 }
1142#if 0
1143 int loop = 0;
1144 double t1 = 0, t2 = 0;
1145 size_t cnt_t1 = 0, cnt_t2 = 0;
1146 size_t prev_cnt = 0;
1147 while (true) {
1148 sleep(1);
1149 const size_t cnt = arg.sh.count;

Callers

nothing calls this directly

Calls 2

get_intMethod · 0.80
gettimeofday_doubleFunction · 0.70

Tested by

no test coverage detected