LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 04-08-2007, 08:15 PM   #1
big_manel
LQ Newbie
 
Registered: Jan 2006
Distribution: Customized Vector Linux
Posts: 17

Rep: Reputation: 0
Automatically measuring command execution times


Hi,

I have been playing around with the bash prompt, and thought of a neat feature to implement: an automatic display of the execution time of the last command.
I tried to use PROMPT_COMMAND but anything defined by this variable will only be ran upon the program termination, whereas I need something that clocks the beginning and end of the program to measure the total execution time.

What other options do you suggest?

Thanks all!
 
Old 04-08-2007, 08:21 PM   #2
cgjones
Member
 
Registered: Nov 2005
Location: Central New York
Distribution: Ubuntu
Posts: 405

Rep: Reputation: 31
There is the GNU time command.
 
Old 04-08-2007, 08:27 PM   #3
big_manel
LQ Newbie
 
Registered: Jan 2006
Distribution: Customized Vector Linux
Posts: 17

Original Poster
Rep: Reputation: 0
Yes, I know about it,

But how can I make it so it it automatically ran along each command? I usually only remember to use it after the command ended.

Thanks!
 
Old 04-08-2007, 08:34 PM   #4
cgjones
Member
 
Registered: Nov 2005
Location: Central New York
Distribution: Ubuntu
Posts: 405

Rep: Reputation: 31
You could create an alias in your ~/.bashrc or ~/.bash_aliases file.
 
Old 04-08-2007, 08:39 PM   #5
big_manel
LQ Newbie
 
Registered: Jan 2006
Distribution: Customized Vector Linux
Posts: 17

Original Poster
Rep: Reputation: 0
That had occurred to me, but what exactly do I alias?

Can I alias something with a regexp? For example:

alias (.*)="time $1"

Thanks once again!
 
Old 04-08-2007, 08:52 PM   #6
cgjones
Member
 
Registered: Nov 2005
Location: Central New York
Distribution: Ubuntu
Posts: 405

Rep: Reputation: 31
I don't think you can do that with an alias, but you might be able to use a shell function. I don't have much experience in that department though.
 
  


Reply



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
command execution time minil Programming 10 08-20-2010 04:59 PM
Measuring TCP Stack execution time anirvana Linux - Networking 0 03-15-2007 08:01 PM
how to automatically block an IP after trying log in multiple times? parv Linux - Security 2 03-04-2007 09:37 PM
can I check the execution of this command? kushalkoolwal Programming 1 10-21-2005 08:44 PM
command execution leonidas Linux - General 1 09-22-2004 12:29 AM

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

All times are GMT -5. The time now is 11:54 PM.

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