最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux實時性能測試工具之cyclictest使用詳解

 更新時間:2026年06月05日 09:28:24   作者:李71~李先森  
這段文章主要介紹了cyclictest工具在Linux系統(tǒng)中的安裝、運行及參數(shù)設(shè)置,重點闡述了其測試內(nèi)核實時性能的方法,包括創(chuàng)建高精度定時線程和測量喚醒延遲,并強調(diào)了不同參數(shù)對測試結(jié)果的影響

cyclictest 是 Linux 系統(tǒng)中 rt-tests 下的用于測試內(nèi)核實時性能的常用工具,通過創(chuàng)建高精度定時線程并測量其喚醒延遲,評估系統(tǒng)的中斷響應(yīng)、調(diào)度延遲等實時特性。

cyclictest 安裝

下面是 cyclictest 的安裝方法,供參考:

# 下載cyclictest原碼
git clone git://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git

# 切換branch stable/v1.0
git checkout stable/v1.0

# 編譯
make

cyclictest 計算延時原理

cyclictest計算延時的原理是通過記錄進程睡眠的開始時間、實際睡眠時間以及真正喚醒并運行的時間,用實際喚醒時間減去實際睡眠時間和睡眠開始時間來得出延時。

  • 程序會記錄進程睡眠的開始時間 t1
  • 進程實際睡眠時間 t2
  • 進程 真正喚醒并運行的時間為 t3
  • 延時結(jié)果即為 t3 - t2 - t1

cyclictest 運行

編譯完成后可以在運行cyclictest, 例如:

sudo ./cyclictest -m -n -p95 -d0 -a 1-17 -t 17

查看參數(shù)可以使用:

./cyclictest -h

./cyclictest: option requires an argument -- 'h'
cyclictest V 1.00
Usage:
cyclictest <options>

-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.
-A USEC  --aligned=USEC    align thread wakeups to a specific offset
-b USEC  --breaktrace=USEC send break trace command when latency > USEC
-B       --preemptirqs     both preempt and irqsoff tracing (used with -b)
-c CLOCK --clock=CLOCK     select clock
                           0 = CLOCK_MONOTONIC (default)
                           1 = CLOCK_REALTIME
-C       --context         context switch tracing (used with -b)
-d DIST  --distance=DIST   distance of thread intervals in us, default=500
-D       --duration=TIME   specify a length for the test run.
                           Append 'm', 'h', or 'd' to specify minutes, hours or days.
         --latency=PM_QOS  write PM_QOS to /dev/cpu_dma_latency
-E       --event           event tracing (used with -b)
-f       --ftrace          function trace (when -b is active)
-F       --fifo=<path>     create a named pipe at path and write stats to it
-h       --histogram=US    dump a latency histogram to stdout after the run
                           US is the max latency time to be be tracked in microseconds
                           This option runs all threads at the same priority.
-H       --histofall=US    same as -h except with an additional summary column
         --histfile=<path> dump the latency histogram to <path> instead of stdout
-i INTV  --interval=INTV   base interval of thread in us default=1000
-I       --irqsoff         Irqsoff tracing (used with -b)
-l LOOPS --loops=LOOPS     number of loops: default=0(endless)
         --laptop          Save battery when running cyclictest
                           This will give you poorer realtime results
                           but will not drain your battery so quickly
-m       --mlockall        lock current and future memory allocations
-M       --refresh_on_max  delay updating the screen until a new max
                           latency is hit. Userful for low bandwidth.
-n       --nanosleep       use clock_nanosleep
         --notrace         suppress tracing
-N       --nsecs           print results in ns instead of us (default us)
-o RED   --oscope=RED      oscilloscope mode, reduce verbose output by RED
-O TOPT  --traceopt=TOPT   trace option
-p PRIO  --priority=PRIO   priority of highest prio thread
-P       --preemptoff      Preempt off tracing (used with -b)
         --policy=NAME     policy of measurement thread, where NAME may be one
                           of: other, normal, batch, idle, fifo or rr.
         --priospread      spread priority levels starting at specified value
-q       --quiet           print a summary only on exit
-r       --relative        use relative timer instead of absolute
-R       --resolution      check clock resolution, calling clock_gettime() many
                           times.  List of clock_gettime() values will be
                           reported with -X
         --secaligned [USEC] align thread wakeups to the next full second
                           and apply the optional offset
-s       --system          use sys_nanosleep and sys_setitimer
-S       --smp             Standard SMP testing: options -a -t -n and
                           same priority of all threads
        --spike=<trigger>  record all spikes > trigger
        --spike-nodes=[num of nodes]
                           These are the maximum number of spikes we can record.
                           The default is 1024 if not specified
         --smi             Enable SMI counting
-t       --threads         one thread per available processor
-t [NUM] --threads=NUM     number of threads:
                           without NUM, threads = max_cpus
                           without -t default = 1
         --tracemark       write a trace mark when -b latency is exceeded
-T TRACE --tracer=TRACER   set tracing function
    configured tracers: none
-u       --unbuffered      force unbuffered output for live processing
-U       --numa            Standard NUMA testing (similar to SMP option)
                           thread data structures allocated from local node
-v       --verbose         output values on stdout for statistics
                           format: n:c:v n=tasknum c=count v=value in us
-w       --wakeup          task wakeup tracing (used with -b)
-W       --wakeuprt        rt task wakeup tracing (used with -b)
         --dbg_cyclictest  print info useful for debugging cyclictest

簡單介紹下一些參數(shù):

  • -m 鎖定進程內(nèi)存,防止頁交換影響實時性,高精度測試時避免內(nèi)存抖動。
  • -n 使用 clock_nanosleep 替代 nanosleep,提高時間精度。
  • -p 設(shè)置線程優(yōu)先級(需 root 權(quán)限)。(Linux 中 SCHED_FIFO 優(yōu)先級范圍通常為 1-99)
  • d0 CPU上有多個實時線程時,每個線程喚醒時間的間隔增量。當設(shè)置為0時,意味著所有線程將在同一時間被喚醒。
  • -a 綁定線程到指定 CPU 核心,例如1-17 綁定到 CPU 1 到 17。
  • -t 指定測試線程數(shù)量。

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

尼木县| 淳安县| 陵水| 镇远县| 孝义市| 海安县| 鹿泉市| 平顶山市| 雷州市| 托克托县| 阜南县| 潜江市| 鲁甸县| 江陵县| 修文县| 乌兰察布市| 澄迈县| 新蔡县| 商城县| 开平市| 多伦县| 平顺县| 尖扎县| 洪雅县| 惠安县| 乌拉特前旗| 泊头市| 阳西县| 绍兴市| 洛南县| 衡山县| 合山市| 鲁山县| 会理县| 同德县| 祁东县| 博野县| 鄂尔多斯市| 鄂托克旗| 井冈山市| 金堂县|