Solved

TIME command

Posted on 1998-08-26
2
306 Views
Last Modified: 2010-04-21
When running a program within the time command three values are given: REAL, USER and SYSTEM. For benchmarking purposes, which value do I use if I want execution time irrespective of machine overhead?
0
Comment
Question by:rsorrent
2 Comments
 
LVL 3

Accepted Solution

by:
elfie earned 50 total points
Comment Utility
Real time is the differnce between the starting time and ending time.(elapsed time)

User time is the cpu time spend in 'user' coding.
system time is the time spend in executing 'system' code.

If you run on a clean system (no overhead) you will see that adding user and system time will give you (approximately) the real time.

If you have no 'clean' system, just take user and system time, and it will give you a good indication for benchmarking.

On a heavy loaded system, 'system' time can increase due to a higher number of page faults, swap out/in, and other interruptions.

Always keep in mind that there is always a difference between a first run and the next executions of a program. Executing a program a second time, mostly means thah the program is still i memory, and thus requires less startup time.
0
 
LVL 2

Expert Comment

by:JYoungman
Comment Utility
Any of the three, still, depending on what you mean by "machine overhead".  Perhaps if I explain the three times, you'll be able to choose the one you want.

When a program runs, it uses the CPU for up to 100% of the time it is running.  If it spends most of its time waiting for data from disks or terminals, or waiting for disk writes to complete, it may only use 1% of the CPU's time.  In this case, REAL time may be one second (the program took 1s to finish) but (USER+SYSTEM) may only be 0.01s.

USER time is time your program spends actually using the CPU to execute its own instructions.  SYSTEM time is time spent by the kernel using the CPU on behalf of that program, to fulfil requests that the program makes.   Here is an example program:-

[james@noisy james]$ cat us.c
#include <sys/time.h>
#include <unistd.h>

int main()
  {
  int i;
  struct timeval tv;
  struct  timezone tz;
  for (i=0; i<1000000; ++i)
    gettimeofday(&tv, &tz);
  return 0;
  }
[james@noisy james]$ make CFLAGS="-O2" LDLIBS= us
cc -O2  -g  us.c   -o us
[james@noisy james]$ time ./us
0.60user 1.80system 0:02.41elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (60major+7minor)pagefaults 0swaps

Here we see that most of the execution time was spent using the CPU, but 1.8s of that (75%) was SYSTEM (i.e. kernel) time.

If you're benchmarking a database, wall-clock time taken to complete a task may be the best measurement.   On the other hand, for a compute-intensive task, USER or (USER+SYSTEM) may be the best measures.


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now