Clock how long it takes code to run?

  • Thread starter Thread starter Steph
  • Start date Start date
S

Steph

Hello. I have several pieces of code that do the same exact thing,
but are written differently. Is there a way to measure the time it
takes for a piece of code to run so I can determine which runs
fastest? Thanks!!
 
Hello. I have several pieces of code that do the same exact thing,
but are written differently. Is there a way to measure the time it
takes for a piece of code to run so I can determine which runs
fastest? Thanks!!

Here's a simple method that works for me. It's not terribly accurate -
you get fairly significant variations depending on what else your system
is doing; best to use an average of several runs...
Dim m As Single, n As Single, o As Single
m = Timer
'your code here
n = Timer
o = n - m
MsgBox o
 
To start with, at various points in my code I use, e.g.

[h1].Value = Time
[h2].Value = Time
[h3].Value = Time
[h4].Value = Time etc

This enables me to determine time taken for a particular piece of code to
execute. - Works for me!

Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top