ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Time comparison (https://www.excelbanter.com/excel-programming/335267-time-comparison.html)

Gixxer_J_97[_2_]

Time comparison
 
Hi all

I am trying to figure out what section of my code is running the longest.

how do i compare two times (ie subtract the two so that i can get a total
time run)

sub MyCode()
dim t1, t2, total
t1=time
<my code
t2=time

total=<how do i work with the time here
msgbox total
end sub

is this the correct way to do this or is there a better way?

and secondly is there a way to write one sub and have it triggered any time
that code is run, without putting a call to it in each of my functions?

basically i want to see how long each section of my code takes to run, so i
can see where the slowdowns are and possibly re-write, etc


tia!

J

sebastienm

Time comparison
 
Hi,

t1=Timer( )
....
t2=Timer( )

total = t2-t1
--
Regards,
Sébastien


"Gixxer_J_97" wrote:

Hi all

I am trying to figure out what section of my code is running the longest.

how do i compare two times (ie subtract the two so that i can get a total
time run)

sub MyCode()
dim t1, t2, total
t1=time
<my code
t2=time

total=<how do i work with the time here
msgbox total
end sub

is this the correct way to do this or is there a better way?

and secondly is there a way to write one sub and have it triggered any time
that code is run, without putting a call to it in each of my functions?

basically i want to see how long each section of my code takes to run, so i
can see where the slowdowns are and possibly re-write, etc


tia!

J



All times are GMT +1. The time now is 06:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com