unix – 如何理解时间命令的输出?

前端之家收集整理的这篇文章主要介绍了unix – 如何理解时间命令的输出?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图弄清楚我的代码性能,但我不明白时间命令的输出,任何人都可以解释什么是时间命令输出的意思。

以下是我得到的:

time ./filereader 

real    0m0.193s
user    0m0.012s
sys 0m0.056s

什么是真实的,用户的,系统的?

From: http://zch051383471952.blogspot.com/2010/01/different-of-real-user-sys-time.html

Real refers to actual elapsed time;
User and Sys refer to cpu time used
only by the process.

  • Real is wall clock time – time from start to finish of the call. This is
    all elapsed time including time slices
    used by other processes and time the
    process spends blocked (for example if
    it is waiting for I/O to complete).
  • User is the amount of cpu time spent in user-mode code (outside the
    kernel) within the process. This is
    only actual cpu time used in executing
    the process. Other processes and time
    the process spends blocked do not
    count towards this figure.
  • Sys is the amount of cpu time spent in the kernel within the process. This means executing cpu time spent in system calls within the kernel,as opposed to library code,which is still running in user-space. Like ‘user’,this is only cpu time used by the process.
原文链接:https://www.f2er.com/bash/388450.html

猜你在找的Bash相关文章