| 58 | } |
| 59 | |
| 60 | static void *RoutineRunFunc(void *arg) { |
| 61 | co_enable_hook_sys(); |
| 62 | |
| 63 | CoWorkerCtx_t *ctx = static_cast<CoWorkerCtx_t*>(arg); |
| 64 | BenchMark *bm = ctx->bm; |
| 65 | const int vtid = ctx->vtid; |
| 66 | |
| 67 | PoissonDistribution pd(bm->GetRoutineSleepTimeMS()); |
| 68 | uint64_t sleep_ms; |
| 69 | int ret; |
| 70 | uint64_t used_time_ms{0}; |
| 71 | struct timespec t1, t2; |
| 72 | |
| 73 | while (1) { |
| 74 | sleep_ms = pd.GetNextIntervalTimeMs(); |
| 75 | if (sleep_ms > used_time_ms) sleep_ms -= used_time_ms; |
| 76 | else sleep_ms = 0; |
| 77 | if (sleep_ms) poll(nullptr, 0, sleep_ms); |
| 78 | |
| 79 | clock_gettime(CLOCK_MONOTONIC, &t1); |
| 80 | ret = bm->TaskFunc(vtid); |
| 81 | |
| 82 | clock_gettime(CLOCK_MONOTONIC, &t2); |
| 83 | used_time_ms = DiffTimespecMS(t1, t2); |
| 84 | |
| 85 | bm->Stat(vtid, ret, used_time_ms, sleep_ms); |
| 86 | } |
| 87 | |
| 88 | return NULL; |
| 89 | } |
| 90 | |
| 91 | class StatData { |
| 92 | public: |
nothing calls this directly
no test coverage detected