Solved

Responsiveness of My.Computer.Clock.TickCount, and ways to test speed

Posted on 2006-10-22
3
188 Views
Last Modified: 2010-04-23

Hey, I'm trying to speed tweak my code, and I've put a bunch of Debug.Print(My.Computer.Clock.TickCount)'s (to get a sense for which parts are slowest) in a particularly time consuminng procedure and here's a weird thing -- it seems like the My.Computer.Clock.TickCount calls themselves are slowing down the procedure -- anyone else seen that?

Aside from that, anybody have a better or slick way of trying to zero in on the time consuming parts of your code?
0
Comment
Question by:riceman0
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 48

Assisted Solution

by:AlexFM
AlexFM earned 250 total points
ID: 17786863
The main problem of TickCount is low precision - about 20 ms. Of course, Debug.Print + time counting change execution time, but there is nothing to do with this.
For high precision time counting use StopWatch class.
0
 
LVL 34

Accepted Solution

by:
Sancler earned 250 total points
ID: 17792618
Although I agree with AlexFM about the lack of precision using Ticks, my attitude is that any case in which that degree of precision matters is not likely to be the real problem.  Users are unlikely to be bothered by nanosecond differences.

In investigating which is the slowest part of any code what matters is the relative result, not the absolute.  Yes, the actual process of timing different elements of code may affect how long that code takes to execute but, so far as I know, it does so to the same extent whatever the underlying code is.  

So I start with Tick prints at a number of points.  If those highlight major (particularly unexpected) differences in particular areas, I refine them within those areas.  If I get down to a level at which that approach does not produce meaningful results in terms of precision I then program specific test routines, looping the code in those areas a sufficient number of times to make the relative results meaningful.

But my watchword is always "does it matter?".  Nanosecond differences do matter if they are repeated enough times.  Hence the looping tests if it gets down to that level.  Otherwise ...

Roger
0
 
LVL 34

Expert Comment

by:Sancler
ID: 17878215
After sales service ;-)

>>
Yes, the actual process of timing different elements of code may affect how long that code takes to execute but, so far as I know, it does so to the same extent whatever the underlying code is.
<<

Or perhaps not, at least with StopWatch.  See here

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_22047746.html

Roger
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question