You are not logged in.

#1 2008-08-28 13:58:27

funkyou
Member
From: Berlin, DE
Registered: 2006-03-19
Posts: 848
Website

[solved] Measuring how much time a bash function takes to run?

Hi there,

a (hopefully) simple question for the bash gods out there :)

Lets say i have a script looking like this:

#!/bin/bash

some_function() {
                doing something
}

some_function

How can i measure the time (preferably in human-readable form: minutes or even hours) the bash function takes for a run?
I know about "time", but i want to do it directly inside the script...

Google tells me nothing, apart from one site where i have to pay for a solution :/

Thanks for any suggestions

Jan

Last edited by funkyou (2008-09-01 13:21:04)


want a modular and tweaked KDE for arch? try kdemod

Offline

#2 2008-08-28 14:18:59

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: [solved] Measuring how much time a bash function takes to run?

iphitus@laptop:~$ sh test.sh 
Hi
Bye

real    0m10.002s
user    0m0.000s
sys     0m0.003s
iphitus@laptop:~$ cat test.sh 
somefunc(){
    echo "Hi"
    sleep 10
    echo "Bye"
}
time somefunc

Time appears to work within bash scripts too smile

Offline

#3 2008-08-28 15:10:52

funkyou
Member
From: Berlin, DE
Registered: 2006-03-19
Posts: 848
Website

Re: [solved] Measuring how much time a bash function takes to run?

So simple i didnt even consider trying it, thanks! smile


want a modular and tweaked KDE for arch? try kdemod

Offline

Board footer

Powered by FluxBB