LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-03-2008, 03:17 PM   #1
macdojo
LQ Newbie
 
Registered: Apr 2008
Posts: 2

Rep: Reputation: 0
Question Inaccuracy of 'time' bash command


Hi,

I am using 'time' command to see how long a process takes to complete. The command displays 'real', 'user', and 'sys'. The value of 'real' is always greater than the sum 'user' and 'sys'. My question is how can the difference can be explained. In the man page of 'time' under "accuracy", it's said that:

"The elapsed time is not collected atomically with the execution of
the program; as a result, in bizarre circumstances (if the `time'
command gets stopped or swapped out in between when the program being
timed exits and when `time' calculates how long it took to run), it
could be much larger than the actual execution time."

This kinda explains but it's said to happen in only 'bizarre' circumstances. then how do you account for the difference under 'normal' circumstances since 'real' is ALWAYS greater than the sum of the other two?
 
Old 04-03-2008, 03:27 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Linux Mint 17, Debian 8
Posts: 7,865

Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
Quote:
Originally Posted by macdojo View Post
Hi,

how do you account for the difference under 'normal' circumstances since 'real' is ALWAYS greater than the sum of the other two?
Real is clock time. user and sys are CPU time. Under normal circumstances such as a file copy the CPU is only used a fraction of clock time.

--------------------
Steve Stites
 
Old 04-03-2008, 04:40 PM   #3
macdojo
LQ Newbie
 
Registered: Apr 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Let me see if I come to a correct conclusion from your provided facts.

1 cpu second is still 1 real second and real is clock time and user/sys are cpu time. real is the time for the process being timed to enter and exit but during which there are other higher priorty, may or may not be related, processes that run and real account for them in its value. user/sys are the exact time consumed by the CPU to carry out the process being timed.

Is this along the line of what's going on with 'time' command?

Thanks!
 
Old 04-03-2008, 07:59 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,699

Rep: Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494
Very close. It's more like
cpu = time spent in cpu
user = time spent in user mode (ie not inc kernel work)
time = how long it took between pressing enter and completion, which, as you pointed out also includes time spent swapped out whilst other progs run.
you can also try using the cmd
\time prog
as this is a GNU variation that gives more info.
 
Old 05-29-2008, 08:48 AM   #5
zail
LQ Newbie
 
Registered: May 2008
Location: Minsk, Belarus
Distribution: Debian testing
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by macdojo View Post
then how do you account for the difference under 'normal' circumstances since 'real' is ALWAYS greater than the sum of the other two?
Don't forget about SMP systems. In some cases 'real' stat can be smaller than 'usr'+'sys'.

This can be helpful:
http://www.ncsa.uiuc.edu/UserInfo/Re...gd/2365c62.htm
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script - I want some time delay between each command is executed bbmak Linux - Newbie 2 12-21-2007 04:35 AM
Bash time of day processing keith.brown Programming 1 05-18-2007 09:06 PM
Bash - Time difference desnotes Programming 1 07-15-2006 01:27 AM
bash: <command name> command not found smash Programming 5 03-13-2006 09:48 AM
See the time of each bash command suguru Linux - Newbie 2 07-24-2004 03:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration