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

Method test_22

client/hstest.cpp:1359–1402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1357}
1358
1359void
1360hstest_thread::test_22(int num)
1361{
1362 /* dd if=/dev/zero of=dummy.dat bs=1024M count=100 */
1363 unsigned int id = arg.id;
1364 std::string err;
1365 auto_file filefd;
1366 char fname[1024];
1367 snprintf(fname, sizeof(fname), "dummy.dat");
1368 int open_flags = O_RDONLY | O_DIRECT;
1369 filefd.reset(open(fname, open_flags, 0644));
1370 if (filefd.get() < 0) {
1371 fprintf(stderr, "open: %s: %d %s\n", fname, errno, strerror(errno));
1372 return;
1373 }
1374 char buf_x[4096 * 2];
1375 char *const buf = (char *)(size_t(buf_x + 4096) / 4096 * 4096);
1376 unsigned long long count = 0;
1377 drand48_data randbuf;
1378 unsigned long long seed = time(0);
1379 seed *= 10;
1380 seed += id;
1381 srand48_r(seed, &randbuf);
1382 for (unsigned int i = 0; i < arg.sh.loop; ++i) {
1383 double kf = 0;
1384 drand48_r(&randbuf, &kf);
1385 kf *= (209715200 / 1);
1386 // fprintf(stderr, "v=%f\n", kf);
1387 off_t v = static_cast<off_t>(kf);
1388 v %= (209715200 / 1);
1389 v *= (512 * 1);
1390 const double tm1 = gettimeofday_double();
1391 const ssize_t r = pread(filefd.get(), buf, (512 * 1), v);
1392 const double tm2 = gettimeofday_double();
1393 if (r < 0) {
1394 fprintf(stderr, "pread: %s: %d %s\n", fname, errno, strerror(errno));
1395 return;
1396 }
1397 ++count;
1398 ++op_success_count;
1399 arg.sh.increment_count();
1400 set_timing(tm2 - tm1);
1401 }
1402}
1403
1404void
1405hstest_thread::operator ()()

Callers

nothing calls this directly

Calls 4

increment_countMethod · 0.80
gettimeofday_doubleFunction · 0.70
resetMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected