?
Solved

TIME command

Posted on 1998-08-26
2
Medium Priority
?
326 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
elfie earned 200 total points
ID: 2006796
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
ID: 2006797
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

765 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