For faster navigation, this Iframe is preloading the Wikiwand page for time (Unix).

time (Unix)

此条目翻译质量不佳,原文在en:time (Unix)。翻译者可能不熟悉中文或原文语言,也可能使用了机器翻译。请协助翻译本条目或重新编写,并注意避免翻译腔的问题。明显拙劣的翻译请改挂((d|G13))提交删除。

time是一个Unix操作系统上的命令。它可以用于确定执行特定命令持续的时间。

用法

[编辑]

要使用该命令,只需在任何命令前加上time,如:

time ls

当命令完成时,time 将计算并报告执行ls命令所花费的用户CPU时间、系统CPU时间和真实时间。不同版本的命令输出格式不一,有的会给予额外的统计数据,如下面的例子:

 $ time host wikipedia.org
 wikipedia.org has address 207.142.131.235
 0.000u 0.000s 0:00.17 0.0%      0+0k 0+0io 0pf+0w
 $

time(1) 可以作为一个独立的程序存在(如GNU time)或作为shell内建命令(例如在tcshzsh中)。

用户时间与系统时间

[编辑]

第一次看到时,术语“用户CPU时间”可以会有点误导。需要明确的是,总CPU时间是指CPU花费在程序执行操作的时间,及CPU花费在内核为该程序执行系统调用的时间组合。当程序在数组中循环时,将累加到用户CPU时间。相反,当一个程序执行如execfork系统调用时,将累加到系统CPU时间。

真实时间与CPU时间

[编辑]

在这里,术语“真实时间”指的是“挂钟”经过的时间,就像用秒表计时一样。总CPU时间(用户时间+系统时间)可能会大于或小于该值。因为一个程序可能会花时间来等待,并且不执行操作(无论是在用户还是系统模式中),实际时间可能大于总CPU时间。因为程序可能会fork子程序,而他们的CPU时间(用户和系统)会被加到time报告的值,总CPU时间可能大于实际的时间。

操作方法

[编辑]

根据time的GNU实现原始码,大多数显示的资讯是从wait3系统调用派生的。在没有wait3调用返回状态资讯的系统中,将使用times调用代替。

参见

[编辑]

参考

[编辑]
{{bottomLinkPreText}} {{bottomLinkText}}
time (Unix)
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?