LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 03-29-2011, 05:13 AM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Rep: Reputation: 45
System.time?


Dear all.
(inside R) I am using system.time function to measure the execution time of two functions

> system.time(lapply(seq(1:1000000),returni))
user system elapsed
0.982 0.100 1.057

> system.time(mclapply(seq(1:1000000),returni))
user system elapsed
0.827 0.607 1.502


As this system.time uses the unix time functions I would like to ask your help understand the output (user,system,elapses) so to figure out which of the two functions is faster or not.

Regards
Alex
 
Old 03-29-2011, 11:09 AM   #2
16pide
Member
 
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
my understanding is this:
user is the time the processor spent running your application
system is the time the system used the processor to service system calls that your program used
elapse is the time difference between program start and program end

user time can be smaller than elapse because other programs are also running on the system at the same time.
also, if the program asks for data from disk for example, then while that data is coming into memory, the processor switches to other programs that could use those processor cycles.

You need to research on schedulers, multitasking, system calls, etc ...

Anyway, in your case above, the fast program is lapply because user+system is lower than with mclapply, so it uses less processor (so potentially less electricity).
More importantly for you, elapsed time is lower, so if you include it in a script, your script can get on with the next command half a second before. It would really become important if you're running that command thousands of times in a loop in a script.
 
1 members found this post helpful.
Old 04-11-2011, 04:30 AM   #3
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Original Poster
Rep: Reputation: 45
Quote:
Originally Posted by 16pide View Post
my understanding is this:
user is the time the processor spent running your application
system is the time the system used the processor to service system calls that your program used
elapse is the time difference between program start and program end

user time can be smaller than elapse because other programs are also running on the system at the same time.
also, if the program asks for data from disk for example, then while that data is coming into memory, the processor switches to other programs that could use those processor cycles.

You need to research on schedulers, multitasking, system calls, etc ...

Anyway, in your case above, the fast program is lapply because user+system is lower than with mclapply, so it uses less processor (so potentially less electricity).
More importantly for you, elapsed time is lower, so if you include it in a script, your script can get on with the next command half a second before. It would really become important if you're running that command thousands of times in a loop in a script.

If I got it right I should be mostly intrested about elapsed time. I want a script/program to run as fast as possible.I do not care about power consumption or how I much stress my cpu.

Do you agree with that ?

regards
Alex
 
Old 04-12-2011, 03:13 AM   #4
16pide
Member
 
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
Quote:
Originally Posted by alaios View Post
If I got it right I should be mostly intrested about elapsed time. I want a script/program to run as fast as possible.I do not care about power consumption or how I much stress my cpu.

Do you agree with that ?

regards
Alex
Probably, yes. Unless you want to guess how it will behave when the system is loaded heavily with other programs, or you run the command multiple times in parallel.
Multiple processes cannot be using the same processor at the exact same time, but they can be waiting at the same time. Especially if they are not waiting for the same resource, for example one process waits for graphic IO while the other waits for disk IO.

Suppose you're on a mono-cpu machine, your process does 100% user time, no system, no wait, and it lasts one minute.
run it twice in parallel, it will take 2 minutes to run.

Now suppose your process does 1% user time, no system, and 99% wait on the clock, and it lasts one minute.
run it a hundred time in parallel, it will take 1 minute to run. The command would be:
sleep 60

try it with:
time sleep 60

That's a bit extreme, but I think it explains the concept.

Have fun!
 
Old 04-12-2011, 03:34 AM   #5
Walter.Stroebel
LQ Newbie
 
Registered: Apr 2011
Location: Arnhem, The Netherlands
Distribution: CentOS
Posts: 19

Rep: Reputation: 6
Using elapsed time also includes any disk or other I/O which means you might get unpredictable results.
Eg. "time wget some_url" will almost entirely depend on your Internet connection and the server at the other side.
If you are disk-bound (waiting on the disk) you might want to

apt-get install sysstat
or
yum install sysstat

and keep

iostat -k 10

running in another window/console to see disk I/O you are causing.

Regards,
Walter
 
  


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
System time vs Hardware time and Daylight Savings Time Toadman Linux - General 6 03-17-2007 08:12 AM
System time vs Hardware time and Daylight Savings Time Toadman Linux - Networking 6 03-16-2007 07:14 PM
Where does RH8 daily set system time to hardware clock time smartnorman Red Hat 1 05-24-2006 02:42 PM
Setting System Time: kernel in wrong time zone warrenweiss Linux - General 7 05-15-2004 03:25 PM

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

All times are GMT -5. The time now is 04:32 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
Open Source Consulting | Domain Registration