MCPcopy Create free account
hub / github.com/Tencent/phxqueue / RoutineRunFunc

Function RoutineRunFunc

phxqueue/comm/utils/benchmark_util.cpp:60–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60static 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
91class StatData {
92public:

Callers

nothing calls this directly

Calls 4

DiffTimespecMSFunction · 0.85
GetRoutineSleepTimeMSMethod · 0.80
TaskFuncMethod · 0.80
StatMethod · 0.45

Tested by

no test coverage detected