如何获得亚行的shell HZ [英] How to get HZ with ADB shell
问题描述
我怎么能知道亚行的shell的Android内核的HZ值? (无需任何编码)
How can I know HZ value of Android kernel through ADB shell? (without any coding)
我检查如何在终端检查HZ?,但这不是与Android ADB壳工作。
I checked How to check HZ in the terminal?, but this is not work with Android ADB shell.
任何建议?
推荐答案
您可以通过采取经过时间的的jiffies 的和除以所经过的时间获得内核空间HZ值的秒的
You can derive the kernel space HZ value by taking an elapsed time in jiffies and dividing it by the elapsed time in seconds.
您可以得到无论是在系统正常运行的的jiffies 的和的纳秒的从的/ proc / timer_list 文件。
You can get both the system uptime in jiffies and in nanoseconds from the /proc/timer_list file.
- 在系统正常运行时间的纳秒
- 搜索
现在<&纳秒GT;纳秒
行 -
<&纳秒GT;
将在纳秒的 正常运行时间
- System uptime in nanoseconds
- Search for the
now at <nanoseconds> nsecs
line <nanoseconds>
will be the uptime in nanoseconds
- 搜索
的jiffies:其中,jiffies的&GT;
行(任何处理器都可以) -
&LT;&的jiffies GT;
将在正常工作时间的的jiffies 的- 注意:此值通常是通过向前偏移<一个href=\"https://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.5/2.5.62/2.5.62-mm2/broken-out/initial-jiffies.patch\"相对=nofollow>
INITIAL_JIFFIES
内核 - 因此它可能无法启动,在0
。然而,由于我们关心的经过时间的而不是 obsolute运行时间的这应该不会影响到我们的计算结果。
- Search for the
jiffies: <jiffies>
line (any processor will do) <jiffies>
will be the uptime in jiffies- NOTE: This value is typically offset forward by
INITIAL_JIFFIES
in the kernel -- so it may not start counting at0
. Nevertheless, this shouldn't affect the outcome of our calculation since we're concerned with the elapsed time rather than obsolute uptime.
通过在一段经过的周期取这两个值,可以使用下面的公式计算值HZ:
By taking these two values over an elapsed period of time, you can calculate the HZ value using the following equation:
(jiffies_after - jiffies_before) HZ = ----------------------------------------- ((nsecs_after - nsecs_before)/1000000000)
如果你碰巧有
AWK
(可能通过BusyBox的),可以自动计算:
If you happen to have
awk
(perhaps via BusyBox), you can automate this calculation:$ awk '/^now at/ { nsec=$3; } /^jiffies/ { jiffies=$2; } END { print nsec, jiffies; system("sleep 1"); }' /proc/timer_list | awk 'NR==1 { nsec1=$1; jiffies1=$2; } /^now at/ NR>1 { nsec2=$3; } /^jiffies/ NR>1 { jiffies2=$2; } END { dsec=(nsec2-nsec1)/1e9; djiff=(jiffies2-jiffies1); print int(djiff/dsec); }' - /proc/timer_list
由于舍入误差,对HZ值可能稍有偏差;您可能要执行该计算好几次,平均吧。大多数现代内核具有内核空间
HZ
设置为250
。下面是几行相同的命令S $ P $垫说明它是如何工作的:
Here's the same command spread over several lines to clarify how it works:
$ awk ' > /^now at/ { nsec=$3; } > /^jiffies/ { jiffies=$2; } > END { > print nsec, jiffies; > system("sleep 1"); > } > ' /proc/timer_list | awk ' > NR==1 { nsec1=$1; jiffies1=$2; } > /^now at/ NR>1 { nsec2=$3; } > /^jiffies/ NR>1 { jiffies2=$2; } > END { > dsec=(nsec2-nsec1)/1e9; > djiff=(jiffies2-jiffies1); > print int(djiff/dsec); > } > ' - /proc/timer_list
-
/ ^现在/ {纳秒= $ 3; }
- 保存的的纳秒的数量变量
纳秒
/^now at/ { nsec=$3; }
- Save the number of nanoseconds to the variable
nsec
- 保存数量的的jiffies 应用于变量
的jiffies
- Save the number of jiffies to the variable
jiffies
-
打印纳秒,jiffies的;
- 打印出的纳秒和的jiffies 的用空格分隔
print nsec, jiffies;
- Print out nanoseconds and jiffies delimited by a space
- 睡眠1秒钟,prevent一个除以0时,我们计算HZ值
- 进程的/ proc / timer_list 文件
- 管道输出到
AWK
的新实例
- Process the /proc/timer_list file
- Pipe output to a new instance of
awk
- 将
纳秒
和的jiffies
从previousAWK 值$ C $分别为
jiffies1
C>到nsec1
和
- Set the
nsec
andjiffies
values from the previousawk
tonsec1
andjiffies1
respectively
- 中的纳秒的数字保存到变量
nsec2
- Save the number of nanoseconds to the variable
nsec2
- 保存数量的的jiffies 应用于变量
jiffies2
- Save the number of jiffies to the variable
jiffies2
-
统计暨普查局=(nsec2-nsec1)/ 1E9;
- 计算以秒为单位的变更的
dsec=(nsec2-nsec1)/1e9;
- Calculate the change in seconds
- 计算以jiffies中的变更的
- Calculate the change in jiffies
- 打印出的HZ值作为一个整数
- 进程标准输入其次的/ proc / timer_list 文件
- Process the standard input followed by the /proc/timer_list file
这篇关于如何获得亚行的shell HZ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Save the number of nanoseconds to the variable
- 保存的的纳秒的数量变量
- NOTE: This value is typically offset forward by
- 注意:此值通常是通过向前偏移<一个href=\"https://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.5/2.5.62/2.5.62-mm2/broken-out/initial-jiffies.patch\"相对=nofollow>
- Search for the
- 搜索