ZLToolKit icon indicating copy to clipboard operation
ZLToolKit copied to clipboard

It seems like the CPU load statistics for the thread pool are incorrect.

Open Nic-bit opened this issue 1 year ago • 1 comments

截屏2024-02-27 20 30 08 In the run function of the thread pool, startSleep() and sleepWakeUp() are used to obtain the thread execution time and sleep time. Although both are locked, in the case of multiple threads and multiple CPUs, the statistics of execution time and sleep time are incorrect. Ideally, a ThreadLoadCounter should only count the running data of one thread. eg: You can record the start timestamp and end timestamp for a single thread.

截屏2024-02-27 20 30 08 线程池的run函数这里,使用startSleep()和sleepWakeUp()来获取线程执行时间和休眠时间,虽然两个都加锁,但是多线程多cpu的情况下,统计的执行时间和休眠时间不对,理想情况下一个ThreadLoadCounter只统计一个线程的运行数据。eg:可以对单个线程记录开始时间戳和结束时间戳。

TRANS_BY_GITHUB_AI_ASSISTANT

Nic-bit avatar Feb 27 '24 12:02 Nic-bit

Indeed, this can only count the load of one thread. In the case of multiple threads, this statistic should be turned off.

确实 这个只能统计一个线程的负载情况 在多个线程的情况下 应该关闭这个统计

TRANS_BY_GITHUB_AI_ASSISTANT

xia-chu avatar Feb 28 '24 03:02 xia-chu