GNU 和 zsh 时间命令之间的区别
Difference between GNU and zsh time commands
我正在尝试使用 GNU 和 zsh time
命令的最大内存输出,并试图调和我在输出中看到的差异。我的最终目标是捕获 运行 不同大小数据集的程序的峰值 RAM 使用情况。要使用我一直关注的 zsh this example.
$ zsh -i -c 'time ls' > hold
ls --color=auto 0.00s user 0.00s system 40% cpu 0.002 total
avg shared (code): 0 KB
avg unshared (data/stack): 0 KB
total (sum): 0 KB
max memory: 0 MB
page faults from disk: 0
other page faults: 335
有了 GNU 时间,我明白了...
$ /usr/bin/time -f %M ls > hold
3632
我认为 这个GNU 时间告诉我ls
使用了3.6 KB 的RAM,但是zsh 版本使用了none。当我为更多的命令重复这个时,我也得到了差异...
$zsh -i -c 'time program > hold'
program > hold 16.36s user 0.64s system 99% cpu 17.063 total
avg shared (code): 0 KB
avg unshared (data/stack): 0 KB
total (sum): 0 KB
max memory: 94 MB
page faults from disk: 0
other page faults: 25361
当我观看顶部屏幕时,看起来 RES 列确实达到了 94 MB 的峰值,尽管 VIRT 列为 127 MB。按 GNU 时间...
$ /usr/bin/time -f %M my_program > hold
387088
或 ~387 MB。
谁能帮我弄清楚为什么会有差异以及我在这里遗漏了什么?
我认为 zsh 没有时间命令。可能是错误的,但 -c
看起来像 "run this shell command",所以它正在搜索你的 time
路径,并且可能会找到你在 运行 中的 /usr/bin/time
22=]。
可能的区别在于格式。尝试将相同的 -f
传递给 zsh 调用。
http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html 不会显示内置时间。您 运行 两种方式都是理智的命令(取决于您的路径中的内容)。
我正在尝试使用 GNU 和 zsh time
命令的最大内存输出,并试图调和我在输出中看到的差异。我的最终目标是捕获 运行 不同大小数据集的程序的峰值 RAM 使用情况。要使用我一直关注的 zsh this example.
$ zsh -i -c 'time ls' > hold
ls --color=auto 0.00s user 0.00s system 40% cpu 0.002 total
avg shared (code): 0 KB
avg unshared (data/stack): 0 KB
total (sum): 0 KB
max memory: 0 MB
page faults from disk: 0
other page faults: 335
有了 GNU 时间,我明白了...
$ /usr/bin/time -f %M ls > hold
3632
我认为 这个GNU 时间告诉我ls
使用了3.6 KB 的RAM,但是zsh 版本使用了none。当我为更多的命令重复这个时,我也得到了差异...
$zsh -i -c 'time program > hold'
program > hold 16.36s user 0.64s system 99% cpu 17.063 total
avg shared (code): 0 KB
avg unshared (data/stack): 0 KB
total (sum): 0 KB
max memory: 94 MB
page faults from disk: 0
other page faults: 25361
当我观看顶部屏幕时,看起来 RES 列确实达到了 94 MB 的峰值,尽管 VIRT 列为 127 MB。按 GNU 时间...
$ /usr/bin/time -f %M my_program > hold
387088
或 ~387 MB。
谁能帮我弄清楚为什么会有差异以及我在这里遗漏了什么?
我认为 zsh 没有时间命令。可能是错误的,但 -c
看起来像 "run this shell command",所以它正在搜索你的 time
路径,并且可能会找到你在 运行 中的 /usr/bin/time
22=]。
可能的区别在于格式。尝试将相同的 -f
传递给 zsh 调用。
http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html 不会显示内置时间。您 运行 两种方式都是理智的命令(取决于您的路径中的内容)。