Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help:how to use timers in functions

Status
Not open for further replies.

austinpowers

Electrical
Joined
Oct 21, 2005
Messages
25
Location
US
how to use timers to know the execution time of a paticular funtion that i am calling.

 
Try looking at the help pages for "tic", "toc" and "profile"

M

--
Dr Michael F Platten
 
actually i am calling a function in my main program twice with different inputs each time.

so i want to know the time taken for two calls.

i tried this

tic
[output1]=function[input1]
toc
time1=toc;

tic
[output2]=function[input2]
toc
time2=toc;

but its not giving correct results ,
i am getting time2<time1

but for my input2 when it goes to that called function it usually takes more time than for input1.so i should get time2>time1

so if i want to know the execution time of a function for two different inputs , is this the right way i am doing
or is there any other way to do this.

if so please let me know about that



 
"tic" and "toc" do not give you a very accurate measurement (although I think you can control the accuracy to a degree). Of course the execution time also varies depending on what else your computer is doing at the time. Maybe have a play with the "cputime" function.

M

--
Dr Michael F Platten
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top