MCPcopy Create free account
hub / github.com/chen3feng/toft / LatencyTest

Function LatencyTest

system/threading/thread_pool_test.cpp:150–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150static void LatencyTest(int loop_count, bool slow_add)
151{
152 int64_t total_latency = 0;
153 int64_t total_add_latency = 0;
154 {
155 ThreadPool threadpool;
156 for (int i = 0; i < loop_count; ++i)
157 {
158 int64_t t0 = RealtimeClock.MicroSeconds();
159 threadpool.AddTask(std::bind(LatencyProc, &total_latency, t0));
160 int64_t t1 = RealtimeClock.MicroSeconds();
161 total_add_latency += t1 - t0;
162 if (slow_add)
163 ThisThread::Sleep(0);
164 }
165 }
166 printf("average latency = %g\n", 1.0 * total_latency / loop_count);
167 printf("average add latency = %g\n", 1.0 * total_add_latency / loop_count);
168}
169
170TEST(ThreadPool, FastAddLatency)
171{

Callers 1

TESTFunction · 0.85

Calls 2

AddTaskMethod · 0.80
MicroSecondsMethod · 0.45

Tested by

no test coverage detected