Solved

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

Posted on 2006-10-22
3
184 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 - SQL Timeout 9 51
VB.NET 2008 Winforms Signing 13 42
get combo value in class 5 24
MYSQL responding very slow 3 50
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…
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 …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 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