介绍

Cyclictest 准确且重复地测量线程的预期唤醒时间与它实际唤醒的时间之间的差异,以提供有关系统延迟的统计数据。 它可以测量由硬件、固件和操作系统引起的实时系统延迟。

安装

rt-tests 安装:https://wiki.linuxfoundation.org/realtime/documentation/howto/tools/rt-tests

使用

sudo cyclictest -a 0 -n -N -q --threads=1 --priority=90 --interval=200us --loops=0 --duration=3s --histogram=5000ns --histfile=result
-a [CPUSET] --affinity     Run thread #N on processor #N, if possible, or if CPUSET
                           given, pin threads to that set of processors in round-
                           robin order.  E.g. -a 2 pins all threads to CPU 2,
                           but -a 3-5,0 -t 5 will run the first and fifth
                           threads on CPU (0),thread #2 on CPU 3, thread #3
                           on CPU 4, and thread #5 on CPU 5.
-n       --nanosleep       使用 clock_nanosleep
-N       --nsecs           每ns打印一次结果,而不是us(默认是us)
-q       --quiet           使用-q 参数运行时不打印信息,只在退出时打印概要内容
-t [NUM] --threads=NUM     线程的个数;不指定 NUM 时,线程个数为max_cups;没有 -t 选项时,线程个数为1
-p PRIO  --priority=PRIO   最高优先级线程的优先级  使用方法: -p 90 /  --prio=90
-i INTV  --interval=INTV   线程时间间隔,默认为1000us
-D       --duration=TIME   指定要测试多长时间。s(),m(),h(小时),d()
-h       --histogram=US    指定要跟踪的最大的延迟数值,如果指定 -N,则以 ns 为单位
-H       							   输出多一列数据在最右边,表示求和,当只有一个线程时, -H 等价于 -h
         --histfile=<path> 输出直方图到 path
-l LOOPS --loops=LOOPS     循环的个数,默认为0(无穷个),与 -i 间隔数结合可大致算出整个测试的时间,比如 -i 1000  -l 1000000 ,总的循环时间为1000*1000000=1000000000 us =1000s ,所以大致为16分钟多。
-m       --mlockall        锁定当前和将来的内存分配

结果

# Histogram
000000 000000
000001 000000 // 延时为 1ns 在所有循环中占据 0# Total: 000000000 // 在规定延时 histogram 值内,总的循环命中次数
# Min Latencies: 04374 // ns
# Avg Latencies: 05906
# Max Latencies: 08169
# Histogram Overflows: 15000 // 超过 histogram 值的循环次数
# Histogram Overflow at cycle number: // 分别是哪次超过了 histogram 值
# Thread 0: 00000 00001 # 14998 others

stress-ng

https://www.cnblogs.com/fireblackman/p/16747354.html

stress-ng --cpu 3 --taskset 1-3 --timeout 3s # 为 CPU 1-3 创建 3 个 CPU 负载(sqrt),执行 3 s
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐