how to use "time" command
Hi All,
I would want to use the "time" command to measure information about the performance of my own program, including time and memory. Unfortunately I dont know how to use it. Suppose that I have a progrem name TEST. How can I run the "time" command and save the infor. into a file named log ? At the moment, I could only run: $time TEST If I run: $time -o log TEST It does not run. I use Linux Fedora 4.0, bash Thanks |
What happens with time -o log TEST?
|
Re: how to use "time" command
Quote:
I think it worked the other time i did it. Anyway, you can always redirect the output to a file. The normal way would be "time TEST > log", but "time" prints the output to standard error (stderr) so you need to redirect it too so the command is "time TEST >& log". (in case you are wondering it is the same as "time TEST > log 2>&1") Then if you view the file named "log" it should contain the output of both "time" and "TEST" |
If you are using bash, it has its own built-in version of 'time'. This one does not support the -o option. There is a stand alone version of time that does. Try /usr/bin/time (or /bin/time, depending on your system) instead and see if that works.
|
Quote:
By the way, I would like to know how much memory my program have taken in KB. Does anyone know how should I run the time command to get that infor ? Assume that my program named TEST, please give me an example. Best. |
try
Code:
ps v Code:
grep TEST I believe the RSS field is the one you want. man ps says "resident set size, the non-swapped physical memory that a task has used (in kiloBytes)." |
All times are GMT -5. The time now is 06:52 AM. |