How the time of execution could be checked?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How the time of execution could be checked?
# 1  
Old 07-17-2008
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  
Old 07-18-2008
Look at the "time" command
# 3  
Old 07-18-2008
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  
Old 07-18-2008
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  
Old 07-19-2008
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"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to reduce the execution time

We are trying to execute below script for finding out the occurrence of a particular word in a log file Need suggestions to optimize the script. Test.log size - Approx to 500 to 600 MB $wc -l Test.log 16609852 Test.log po_numbers - 11 to 12k po's to search $more po_numbers xxx1335... (10 Replies)
Discussion started by: KumarPiyush7225
10 Replies

2. Shell Programming and Scripting

To take script execution time

Hello Guys, I would like to know is there a way to take the script execution time For e.g i am having a script.sh i need to write inside he script.sh like Start time : 10-Mar-2016 02:30:35 all code over here ... End time : 10-Mar-2016 03:30:32 Script start time - 02:30:35 ... (7 Replies)
Discussion started by: Master_Mind
7 Replies

3. UNIX for Dummies Questions & Answers

time taken for execution

how much time a particular command or shell script executed there is any command to know this thanks (5 Replies)
Discussion started by: tsurendra
5 Replies

4. Shell Programming and Scripting

get execution time of a script

Hi, I have a simple question. How can I get the execution time of a script and maybe put it in a variable? Another question. How can I get only time and not date and put it in a variable? I tried something with "date" command but with no success... If someone could help me... (8 Replies)
Discussion started by: Moumou
8 Replies

5. Shell Programming and Scripting

time of execution of script

i want to test whether a script has been executed in last 15 days or not....please help how can i do this...is there any copmmand there to know timings of last execution of any script (8 Replies)
Discussion started by: arghya_owen
8 Replies

6. Shell Programming and Scripting

To reduce execution time

Hi All, The below script I run daily and it consumes 2 hours approx. In this I am calling another script and executing the same twice. Is the loop below the cause for the slow process?Is it possible to finetune the program so that it runs in a much faster way? The first script: #!/bin/ksh... (4 Replies)
Discussion started by: Sreejith_VK
4 Replies

7. Shell Programming and Scripting

Estimated execution time

Hi All, One of my script runs (approximately) for 20 to 40 hours Is there any way in unix to find the estimated time required for a shell script(Cron job).ie to find the time required for execution even before the script is executed. Any discussion(pointers) regarding the same is most welcome. (4 Replies)
Discussion started by: Sreejith_VK
4 Replies

8. UNIX for Advanced & Expert Users

specifying an execution time

Hi all, do ny o u'll know how to set a particular execution time for a program??? for eg.: --> during the execution of a file, i call a certain other function. --> while calling this function, my comp hangs. now is there ny way in which i can go to the nxt line of code by aborting the call... (7 Replies)
Discussion started by: VGR
7 Replies

9. UNIX for Dummies Questions & Answers

last execution time

is there a command in Solaris 8 that will show a particular scripts last execution time? (1 Reply)
Discussion started by: cubs0729
1 Replies

10. Programming

execution time

hi , i ve coded a C program in that im using malloc dynamically , it is being called many times in the program The program is to simulate jobs in manufacturing system. the execution time is increasing drastically as the number of jobs are increased. could any body tel what may be the problem... (2 Replies)
Discussion started by: ramki_rk
2 Replies
Login or Register to Ask a Question