You are not logged in.

#1 2007-01-01 18:18:55

arew264
Member
From: Friendswood, Texas, US
Registered: 2006-07-01
Posts: 394
Website

Question Regarding CPU Time

I am a high school student doing a science fair project where I compare the speeds of various programming languages doing specified tasks. I was planning to use the time command to monitor how much cpu time my programs were using, thus eliminating any influence from other programs (in theory anyway). The one thing that confuses me is the difference between user cpu time and system cpu time. These are mentioned everywhere, but never really explained. What's the difference?

EDIT: Fixing typos from the crap keyboard I'm using

Offline

#2 2007-01-02 01:41:59

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: Question Regarding CPU Time

real time is the wallclock time, i.e. the time you wait for the task to complete.
user time is the time needed for the task to be executed by the cpu.
system time is the time spent on doing system calls  like reading/writing to the hard drive or if your task is doing illegal operations like division by zero. So usually the system time is much less than the user time.
Probably the user time is the one that you're interested in here as I assume that the system time won't change much from language to language.

Offline

#3 2007-01-02 02:23:23

arew264
Member
From: Friendswood, Texas, US
Registered: 2006-07-01
Posts: 394
Website

Re: Question Regarding CPU Time

So the system time would include things like loading interpreters, etc?

That would kinda fit with what I'm getting.
Thanks, my results make a lot more sense now.

This also explains why the results change when I run the program twice without rebooting. The user time would stay the same, but the system time would change drastically because everything would still be in memory... probably anyway...

Offline

Board footer

Powered by FluxBB