LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to use "time" command (https://www.linuxquestions.org/questions/linux-general-1/how-to-use-time-command-362162/)

owentn 09-10-2005 04:17 PM

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

Matir 09-10-2005 04:34 PM

What happens with time -o log TEST?

imitheos 09-10-2005 04:48 PM

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"

Matir 09-10-2005 04:51 PM

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.

owentn 09-23-2005 07:14 AM

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.

redjokerx 09-23-2005 07:40 AM

try
Code:

ps v
you can
Code:

grep TEST
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:52 AM.