你可以使用time(1)获得比bash内置的 time (Robert Gamble提到的)更详细的信息 . 通常这是 /usr/bin/time .
编者注:为了确保您调用外部实用程序时间而不是shell的time关键字,请将其调用为/ usr / bin / time . time是POSIX强制实用程序,但它需要支持的唯一选项是-p . 特定平台实现特定的非标准扩展:-v与GNU的时间实用程序一起使用,如下所示(问题标记为linux); BSD / macOS实现使用-l来产生类似的输出 - 请参阅man 1次 .
详细输出示例:
$ /usr/bin/time -v sleep 1
Command being timed: "sleep 1"
User time (seconds): 0.00
System time (seconds): 0.00
Percent of CPU this job got: 1%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.05
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 0
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 210
Voluntary context switches: 2
Involuntary context switches: 1
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0