The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
To reduce execution time Sreejith_VK Shell Programming and Scripting 4 05-13-2008 02:49 AM
Estimated execution time Sreejith_VK Shell Programming and Scripting 4 04-16-2008 09:23 AM
specifying an execution time VGR UNIX for Advanced & Expert Users 7 03-19-2008 05:32 AM
last execution time cubs0729 UNIX for Dummies Questions & Answers 1 01-20-2006 08:45 PM
execution time ramki_rk High Level Programming 2 08-27-2003 09:23 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-17-2008
alex_5161 alex_5161 is offline
Registered User
  
 

Join Date: Jan 2007
Location: Detroit
Posts: 124
How the time of execution could be checked?

I need to see how much time my script uses to execute different part of processing.
Is there anything to get it?

I see the shell biultin variable $SECONDS, but I need much more precise statistic, in mili or micro seconds.

Is there anything available for that?

I use bash shell.

Thank you.
  #2 (permalink)  
Old 07-17-2008
quine quine is offline
Registered User
  
 

Join Date: Mar 2008
Location: Bay Area California
Posts: 68
Look at the "time" command
  #3 (permalink)  
Old 07-18-2008
alex_5161 alex_5161 is offline
Registered User
  
 

Join Date: Jan 2007
Location: Detroit
Posts: 124
I've checked time, timex, times even before posting the question and reviewed 'time' now.
As I understand I need in every comand in my screept add the time and get what: time of executing that one command?
Or redirect the time's output somewhere, take the result and calculate a time from beginning of the script?
Very uncomfortable!
That not what I am looking for.

I would assume to be able to put a line anywhere in script something like that:
Code:
>...
> echo "Processing time from beginning of the script="$(some_time_getting_util)
>...
  #4 (permalink)  
Old 07-18-2008
quine quine is offline
Registered User
  
 

Join Date: Mar 2008
Location: Bay Area California
Posts: 68
You simply pre-pend the "time" command to your script. When your script ends, the execution time, cpu time, etc will be printed to STDOUT...

> time yourscriptname

your script's output....

real 0m0.005s
user 0m0.010s
sys 0m0.000s
>

The last 3 lines are the output of time command... Isn't that what you asked for?
  #5 (permalink)  
Old 07-19-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,421
Something like that ?
Code:
start_time=$(date "+%s.*N")
#...
#do something here
#...
sleep 5
echo "Processing time from beginning of the script = $(echo "$(date "+%s.%N")- $start" | bc) seconds"
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0