LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 02: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, 02:27 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
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, 03: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, 06:59 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 07: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



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 03:35 AM
Bash time of day processing keith.brown Programming 1 05-18-2007 08:06 PM
Bash - Time difference desnotes Programming 1 07-15-2006 12:27 AM
bash: <command name> command not found smash Programming 5 03-13-2006 08:48 AM
See the time of each bash command suguru Linux - Newbie 2 07-24-2004 02:30 PM

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

All times are GMT -5. The time now is 07:45 AM.

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
Open Source Consulting | Domain Registration