Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Stephens' Visual Basic Programming 24-Hour Trainer
This is the forum to discuss the Wrox book Stephens' Visual Basic Programming 24-Hour Trainer by Rod Stephens; ISBN: 978-0-470-94335-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Stephens' Visual Basic Programming 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 6th, 2011, 12:38 PM
Authorized User
Points: 195, Level: 3
Points: 195, Level: 3 Points: 195, Level: 3 Points: 195, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: Tennessee
Posts: 46
Thanks: 27
Thanked 0 Times in 0 Posts
Default TryIt22 video question

In your TryIt22 video you looped through salary and put 2 debug.assert statements in the loop to check for possible erroneous values. You said in a small system it basically has no noticeable effect on performance but on a large system it could have an effect. Is there a reason you did not put the debug.assert statements in the existing loop where you are calculating the results? That would eliminate the separate debug loop but still give you the debug statements.
Reply With Quote
  #2 (permalink)  
Old September 6th, 2011, 02:43 PM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Which loop you put these things in doesn't really matter much because you're still doing the check once per item in the loop. I often try to keep these sorts of checking statements as separate as the rest of the code as possible so (1) the purposes of the loops are kept separate and (2) it's easier to comment out the debugging statements later if you want.

There is one very small difference. It's no big deal so if you're happy with that answer stop reading now. If you want a little extra info, read on.
-----
The Debug.Assert statement is removed from the program when you make a release build. In that case, it doesn't add any extra time to the program at all.

If you have a loop that contains only Debug.Assert statements, then the loop is empty (because the Debug.Assert statements have been removed) but it still exists so it takes a little extra time. My computer can run a loop through about 2.2 million loops per second so the extra time is trivial unless you have a really big loop.

In contrast, if you put the Debug.Assert statement inside a loop that you need to run whether or not the debugging statements are removed, then you don't need to execute that extra empty loop, and that will save you a tiny amount of time.

Because the difference is so small, I would use whichever technique makes the most intuitive sense and not worry about the extra millisecond one method will cost over the other.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
The Following User Says Thank You to Rod Stephens For This Useful Post:
zavodney (September 7th, 2011)
  #3 (permalink)  
Old September 7th, 2011, 12:59 AM
Authorized User
Points: 195, Level: 3
Points: 195, Level: 3 Points: 195, Level: 3 Points: 195, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: Tennessee
Posts: 46
Thanks: 27
Thanked 0 Times in 0 Posts
Default

Thanks, I always like extra info.

Keith Z.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Video Conferencing in C# Bhattachan C# 2005 4 February 18th, 2008 09:07 AM
play online video or video rajanikrishna ASP.NET 2.0 Basics 1 September 17th, 2007 01:01 PM
Video buffering, streaming, and displaying video t CurvyBabe C# 1 March 9th, 2007 01:17 PM
Video Streaming pmishra.mca PHP How-To 1 October 25th, 2006 03:16 AM
Please Help!! Video?? jamyz VB How-To 0 October 15th, 2005 01:22 PM



All times are GMT -4. The time now is 11:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.