Skip to content

Commit c7697d8

Browse files
committed
only collect timing data if requested
1 parent 6c4dd4d commit c7697d8

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/nanothread.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -246,24 +246,28 @@ Task *task_submit_dep(Pool *pool, const Task *const *parent,
246246

247247
Task *task = pool->queue.alloc(size);
248248

249-
#if defined(_WIN32)
250-
QueryPerformanceCounter(&task->time_start);
251-
#elif defined(__APPLE__)
252-
task->time_start = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
253-
#else
254-
clock_gettime(CLOCK_MONOTONIC, &task->time_start);
255-
#endif
249+
if (profile_tasks) {
250+
#if defined(_WIN32)
251+
QueryPerformanceCounter(&task->time_start);
252+
#elif defined(__APPLE__)
253+
task->time_start = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
254+
#else
255+
clock_gettime(CLOCK_MONOTONIC, &task->time_start);
256+
#endif
257+
}
256258

257259
if (func)
258260
func(0, payload);
259261

260-
#if defined(_WIN32)
261-
QueryPerformanceCounter(&task->time_end);
262-
#elif defined(__APPLE__)
263-
task->time_end = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
264-
#else
265-
clock_gettime(CLOCK_MONOTONIC, &task->time_end);
266-
#endif
262+
if (profile_tasks) {
263+
#if defined(_WIN32)
264+
QueryPerformanceCounter(&task->time_end);
265+
#elif defined(__APPLE__)
266+
task->time_end = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
267+
#else
268+
clock_gettime(CLOCK_MONOTONIC, &task->time_end);
269+
#endif
270+
}
267271

268272
if (payload_deleter)
269273
payload_deleter(payload);

0 commit comments

Comments
 (0)