?
Solved

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

Posted on 2006-10-22
3
Medium Priority
?
192 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 1000 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 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month11 days, 19 hours left to enroll

752 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