如何测量一组特定线程的 CPU 时间?
How can I measure CPU time of a specific set of threads?
我在Linux中运行C++程序。
有几个线程池(用于计算,用于io,用于...这样的事情(。
系统调用 clock(( 为我提供了一种测量所有 CPU 内核为进程花费的 CPU 时间的方法。
但是,我想测量计算线程池中的线程所花费的 CPU 时间。
我怎样才能实现它?
谢谢:D
要获取每个线程的CPU clock ID
,您可以使用:pthread_getcpuclockid 使用此CPU clock ID
您可以使用以下命令检索当前线程 CPU 时间: clock_gettime.
以下是演示相同内容的示例代码:
struct timespec currTime;
clockid_t threadClockId;
//! Get thread clock Id
pthread_getcpuclockid(pthread_self(), &threadClockId);
//! Using thread clock Id get the clock time
clock_gettime(threadClockId, &currTime);
相关文章:
- 分别测量每个线程上花费的 CPU 时间(C++)
- C++从多线程 CPU 程序迁移到 GPU
- 如何测量一组特定线程的 CPU 时间?
- 线程SCHED_RR Posix 计时器使用的是 100% CPU
- 在MIDI播放线程上降低CPU
- C++多线程算法创建在同一 CPU 线程上运行的多个线程
- 我有 12 个 CPU,1 个插槽,每个插槽 6 个内核,每个内核 2 个线程 - 这些信息如何对应于 MPI 和 Op
- 如何在 Qt5 中设置线程的 CPU 关联?
- 我的CPU/OS可以处理多少个线程
- 我的多线程游戏始终为100%CPU.如何管理线程活动以减少CPU负载
- 即使使用睡眠,线程也不会放弃CPU时间
- 线程池正在占用所有CPU资源
- 在运行时查找特定线程的CPU核心
- rusage的进程/线程的Cpu时间不可能
- 在每个主机线程(多线程 CPU)上创建一个 cuda 流
- 使用串行端口线程进行 CPU 支持
- 考虑 CPU 提升模式的多线程超线性性能实现
- C++:多线程设计,每个线程都应该同时执行I/O和CPU密集型任务
- 多线程CPU到GPU使用CUDA 7.0/VS2012 c++ /CLI/OpenCV
- 如果已知访问顺序是安全的,如何在没有互斥锁的情况下同步线程/CPU