cns*_*nst 2 performance time zsh
在 中tcsh,有一个非常有用的功能,可以自动让您打印time每个命令的统计信息。可以通过非常简单的方式set time通过名称设置“特殊 shell 变量”来启用它time:
tcsh$ set time\ntcsh$ sleep 1\n0.000u 0.015s 0:01.01 0.9% 0+0k 0+0io 2241pf+0w\ntcsh$ sleep 1 && sleep 0.1\n0.000u 0.000s 0:01.01 0.0% 0+0k 0+0io 2241pf+0w\n0.000u 0.015s 0:00.11 9.0% 0+0k 0+0io 2243pf+0w\ntcsh$\nRun Code Online (Sandbox Code Playgroud)\ntcsh$ man tcsh | fgrep -A2 \'If set to a number,\'\n time If set to a number, then the time builtin (q.v.) executes auto\xe2\x80\x90\n matically after each command which takes more than that many\n CPU seconds. If there is a second word, it is used as a format\n2.257u 0.319s 0:01.52 168.4% 0+0k 0+0io 35517pf+0w\ntcsh$ \nRun Code Online (Sandbox Code Playgroud)\n我已经尝试为 寻找类似的解决方案zsh,但我无法在zshoptions(1)或任何其他页面中找到这样的选项,并且我得到的只是改变 shell 底层功能的广泛配置设置(除了EXTENDED_HISTORY和INC_APPEND_HISTORY_TIME,虽然非常有用,与我正在寻找的不一样)。
zsh没有类似的选项吗?有没有办法打印一组命令中每个命令的执行时间?
\n该选项实际上是 in zshparam,而不是zshoptions,并且被称为REPORTTIME。
zsh% REPORTTIME=
% REPORTTIME=
zsh% sleep 1
sleep 1 0.02s user 0.01s system 2% cpu 1.039 total
zsh% sleep 1 && sleep 0.1
sleep 1 0.03s user 0.01s system 3% cpu 1.094 total
sleep 0.1 0.01s user 0.01s system 17% cpu 0.130 total
zsh%
Run Code Online (Sandbox Code Playgroud)
% man zshparam | fgrep -B1 -A3 'If nonnegative'
REPORTMEMORY
If nonnegative, commands whose maximum resident set size
(roughly speaking, main memory usage) in kilobytes is greater
than this value have timing statistics reported. The format
used to output statistics is the value of the TIMEFMT parameter,
--
REPORTTIME
If nonnegative, commands whose combined user and system
execution times (measured in seconds) are greater than this
value have timing statistics printed for them. Output is
suppressed for commands executed within the line editor,
man zshparam 0.06s user 0.01s system 94% cpu 0.071 total
fgrep -B1 -A3 'If nonnegative' 0.02s user 0.02s system 67% cpu 0.069 total
%
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
636 次 |
| 最近记录: |