开发者

UNIX time command - is input time factored in?

I'm using the unix time command to record times for running a java program.

The first thing my program does when it begins running is ask the user to input a file path.

Is the time taken to type this in and hit return factored into any of the time statistics that this comman开发者_开发百科d returns? The output for my time command is of the form:

.#u #.#s #:#.# #.#% #+#k #+#io #pf+#w

where # is an integer

Thank you


Yes, the time taken to provide input is a part of the real time (3rd entry in your output).

Simple demo:

$ time(sleep 5 ; echo hi | read)

real      0m5.005s
user      0m0.000s
sys       0m0.004s

Here the echo hi will print hi on std output and read will read it. I've added a 5 sec delay before this writing and reading happens. And I've timed the entire thing.

As seen the real time is around 5 sec, which means it takes into account the time the read command took to read the input.

Just to be complete the user time is the time the CPU takes to run the instructions in our program like the loops, the conditionals.
And the sys time is the time taken by the CPU to perform system calls. In our example we see a 4 msec of sys time because there are many sys calls involved in that command like read, write etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜