Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
09-10-2005, 04:17 PM
|
#1
|
LQ Newbie
Registered: Aug 2005
Posts: 6
Rep:
|
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
|
|
|
09-10-2005, 04:34 PM
|
#2
|
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507
Rep: 
|
What happens with time -o log TEST?
|
|
|
09-10-2005, 04:48 PM
|
#3
|
Member
Registered: May 2005
Location: Greece
Posts: 441
Rep: 
|
Re: how to use "time" command
Quote:
Originally posted by owentn
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
|
You are right. "-o" didn't work for me either.
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"
|
|
|
09-10-2005, 04:51 PM
|
#4
|
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507
Rep: 
|
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.
|
|
|
09-23-2005, 07:14 AM
|
#5
|
LQ Newbie
Registered: Aug 2005
Posts: 6
Original Poster
Rep:
|
Quote:
Originally posted by Matir
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.
|
Thank you very much. Now "time" command works correctly.
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.
|
|
|
09-23-2005, 07:40 AM
|
#6
|
Member
Registered: Aug 2004
Location: San Diego
Distribution: Slackware
Posts: 303
Rep:
|
try you can later once you know which column you're looking for.
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:18 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|