Linux - GeneralThis 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.
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.
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 ?
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"
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.