Click to See Complete Forum and Search --> : How to measure system response time of Linux?
Giftz
03-06-2005, 02:47 AM
Our teacher assigned a homework to us : to measure the system response time of a certain OS. Here I want to test the response time in linux.
I searched the web, found a few materials about how to test the linux
kernel,then I got the idea of the time to be measured here(I'm not so sure
about the teacher's meaning):
1)response time -the amount of time it takes a system to process an external request.
2)Latency -the minimum time required to get any kind of response, even one that requires no processing time.
that is, the time measured is the interval between the user commite a
command and the moment the specific process occupy the cpu(Am I right?)
Then I looked through the Linux Test Project web site, and read the
functions of many test tools listed there ,but I didn't find any test tools
that is able to measure the time I want.
So my question is:
1)Does anybody know is there any tool that can measure that time?
2)If there isn't, then if I have to write code by myself , my comprehension
is that I have to add some code in the kernel and recompile it(I haven't try
it before ,is there any suggestions?)
3)If I used some tool to test that time and I got a series results:
t1,t2...tn, then how to calculate the response time?
Icarus
03-06-2005, 11:25 AM
Not sure, but maybe the 'time' command is what you are looking for
time - time a simple command or give resource usage
example, use time with a command like ls
icarus@Daedalus ut2004-stuff $ time ls
UT2004.ini User.ini
real 0m0.007s
user 0m0.003s
sys 0m0.004s
Giftz
03-07-2005, 12:42 AM
Thank you.
I hope the time command will work. But the time result consist of (i) the elapsed real time between invocation and termination, (ii) the user CPU time and (iii) the system CPU time
What I want is the time between the moment user commite the command--I don't know if it means invocation--and the moment the process is being running on cpu .
I will go on trying .
sharth
03-07-2005, 11:19 AM
Originally posted by Giftz
Thank you.
I hope the time command will work. But the time result consist of (i) the elapsed real time between invocation and termination, (ii) the user CPU time and (iii) the system CPU time
What I want is the time between the moment user commite the command--I don't know if it means invocation--and the moment the process is being running on cpu .
I will go on trying . Isin't that.. impossible? Actually let me expand. This. first off, is compeltly hardware and software dependent, so everyone in the class could get wildly different results (and by wildly, I don't mean by that much, because honestly, I don't think that what you're asking for should take that long in real time).
The time from running a program to it's execution would be dependent on what commands are being sent to the processer at any one time, and the priority of those commands compared to the one you wish to run.
Also, the mere attempt to check to see when this program starts to run would, in my opinion, slow down the program itself. Unless you created some kernel module that allowed you to decide exactly what commands in exactly what order get sent in... Since otherwise you couldn't assure yourself that the commands (there would probably, nearly posative be multiple commands needed) to stop the clock happened right after you found out that the program started to run. Heck, you couldn't really compare the starting of the clock to the execution of the program.
But all those times are on a level so minute that it really doesn't matter terribly...
The only command that i can think of would be this...
"time echo"
It won't output anything (the slowest part of most programs), which shortens execution time by a ton. But you still get no real useful output. On a few of the systems that I have access to
// A unix server...
wlynch@strauss:~$ time echo
real 0m0.000s
user 0m0.000s
sys 0m0.000s
// A slower unix server...
wlynch@haydn:~$ time echo
real 0m0.000s
user 0m0.000s
sys 0m0.000s
// my iBook...
host128-14:~ Sharth$ time echo
real 0m0.000s
user 0m0.000s
sys 0m0.000s
XiaoKJ
03-07-2005, 12:00 PM
I believe its (i), but you should ask for more opinions.
bwkaz
03-07-2005, 07:16 PM
Originally posted by Giftz
What I want is the time between the moment user commite the command--I don't know if it means invocation--and the moment the process is being running on cpu. This has VERY little to do with the kernel. ;)
It has almost everything to do with bash. The amount of time between you hitting return in your shell, and the program starting, will be (almost) completely determined by the code that bash runs to receive input, parse the command, and then call the fork() syscall followed by one of the exec...() functions (which all call the execve() syscall, eventually).
Most of the tiny percentage of the elapsed time that's not spent executing code inside bash, will be spent executing code inside the C library. This is code to massage exec...()-family function calls into the form that execve() takes, code to manage the return value from fork(), etc. A tiny percentage of that leftover time will be spent inside the kernel, but (at a guess) it'll probably be about 1/100th of the total time spent.
(Note that timing "echo" is not a good test of what would happen if the program does nothing, either. For one, "echo" does print a single blank line. ;) For two, "echo" on its own is a shell builtin command, which doesn't run a program. Instead, you might be better off timing /bin/false or /bin/true, because they really don't do anything. When I time both false and true, I get 0.001s real, 0.001s user, and 0.000s system, but I've only done it once. "echo" gives 0.000s for all three.)
Fryguy8
03-08-2005, 01:00 AM
not sure if this is a programming class or not, but "time to process an external request" why not use a system call?
getcurrenttimeinnanoseconds
system("command")
Where "command" is a command that the very first thing it does it getcurrenttimeinnanoseconds. then you can compare these 2 values and get a reasonable approximation.
Giftz
03-08-2005, 02:29 AM
Today I find that there is a misunderstanding between me and my teacher
, in fact, it's my fault, I didn't listen to the lecture carefully enough,so I missed the defination of the time to be measured.
The time is that the interval between user commit the command and the
output is finally done.
I appologize for my mistake here and Thank you for replying this.
Now the problem becomes a little simpler, the time() can do that, there
are some test tool can do that , and I can write some code to do that.
I will write a report about this after I testing the time. If anyone want
the result I will post again.
Pafnoutios
03-08-2005, 02:04 PM
Originally posted by Giftz
The time is that the interval between user commit the command and the
output is finally done.
This still depends on which command you use.
$ time date
Tue Mar 8 12:54:42 EST 2005
real 0m0.144s
user 0m0.003s
sys 0m0.000s
# time make bzImage
...
real 7m43.765s
user 6m19.430s
sys 0m31.040s