LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 09-10-2005, 04:17 PM   #1
owentn
LQ Newbie
 
Registered: Aug 2005
Posts: 6

Rep: Reputation: 0
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
 
Old 09-10-2005, 04:34 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
What happens with time -o log TEST?
 
Old 09-10-2005, 04:48 PM   #3
imitheos
Member
 
Registered: May 2005
Location: Greece
Posts: 441

Rep: Reputation: 141Reputation: 141
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"
 
Old 09-10-2005, 04:51 PM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
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.
 
Old 09-23-2005, 07:14 AM   #5
owentn
LQ Newbie
 
Registered: Aug 2005
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 09-23-2005, 07:40 AM   #6
redjokerx
Member
 
Registered: Aug 2004
Location: San Diego
Distribution: Slackware
Posts: 303

Rep: Reputation: 31
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)."
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 07:42 AM
Where to download precompiled bash binaries, such as "time" and "top"? elinuxqs Linux - Newbie 12 11-14-2005 08:36 PM
Lost DHCP Lease when putting computer in "Standby" mode for a "long" time pnellesen Linux - Networking 1 01-06-2005 11:44 PM
Tiny Sofa 2.0 - I thought "halt", "reboot" were only root command ?? sorcerer Linux - Distributions 1 08-21-2004 03:28 PM
"segmentation error" when issuing "useradd" command through terminal with RH 9.0 kaihuang Linux - General 0 10-21-2003 11:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration