Writers' Community!
Home Page Two Columnists Submit an Article FAQs Contact Author Login
Article Submission
We Need YOUR Articles!
We'll Promote Them for FREE!

Author Login

New Authors
Register Here


Now Serving 5,682 Authors
48,470 Quality Articles
& 6,377 Current Users Online!
Featured Authors
Scot McKay - Dating Coach (4,403)
Tex Norman (3,934)
Gregory Lewis (394)
Sandra E. Graham (2,066)
David Pekrul (367)
Stephany Springer (31,900)
Robert Melaccio, Sr. (6,338)
Laura Trahan (32,796)
Ronyae (160)
David Tanguay (7,551)
Dianne Lehmann (2,700)
Angie Lewis (7,171)
Danny Davids (15,668)
Mike Fak (3,929)

View All Featured Authors
Most Recent
Effective Use of MS Project Calendars

Excel for Beginners

The future of PowerPoint?

Shrink Your Technology - How to Work Anywhere, Anytime Out of a Backpack

TCP/IP protocols and configurations.

How TCP/IP and Routing Work

Outsourcing Work

Preventing Malware Downloads with a Spyware Adware Blocker

Why Does Spyware Exist & Tips On How to Stop It

Using Collaboration Software to Increase the Effectiveness of Virtual Teams

Home » Categories » Computers & Networking » Software » Test C# Code Performance Speed » Printer Friendly

Test C# Code Performance Speed

Rated 3.5 out of 5
Rated 5.0 by 1 Reader ?
Rate It  /  View Comments  /  View All Articles submitted by Armando Park
Submitted Wednesday, June 25, 2008
Armando Park (21)
Visual C# Kicks
Log in to become a member of Armando Park's Fan Club!


Programming in C#, as in many languages, provides a limitless way to write applications. So many different programming techniques can vary in your application's speed and efficiency. Learning how to determine which coding techniques are faster is an essential skill.

The simple structure to test out fast C# code run is this:

  • Set up all variables required
  • Set up a DateTime start variable to mark the beginning of the test
  • Initialize a for loop with the code to be tested inside (the amount of trials should be set up to make the total execution time last an appropriate amount)
  • Mark the ending time on a DateTime end variable
  • Subtract the starting time to the ending time
  • The difference can then be compared to other tests

An optional step is to divide the total time it took to execute the C# code and divided by the amount of times the for loop ran.I personally like to compare the total execution times since it reduces the variation in the results.

Usually the first time the code is executed the source code will run slower than normal, so try to run several tests and average out the results.

Also I recommend to test source code from within Visual Studio (the debuggin environment in other words) since source code that runs with the debugger runs a bit slower. This gives a nicer window to compare different bits of source code against their speeds.

Remember that the final Release version of your application will be optimized by the compiler (inline code and such) and will almost always run faster than the debugging version.

If you would like general tips on optimizing C# code also visit the 5 Ways to Optimize C# Code article.






Reprint Rights

Log in to become a member of Armando Park's Fan Club!

Comments on this article:
No comments yet.


Was this article helpful to you? Leave a Public Comment or Question:

 

This Article has been viewed 36 times.
Article added to SearchWarp.com on Wednesday, June 25, 2008
View other articles written by Armando Park (21)


If you found this article interesting, you may want to check out:

Disclaimer:  All information on this site is provided for informational purposes only! By no means is any information presented herein intended to substitute for the advice provided to you by any health care or other professional or organization.


Today's Most Popular
Improve PC Performance - 6 Tips You Must Know.

Introduction to DQL-Documentum Query Language

Elimination of Spooler Subsystem App problem. Easy and quick.

Linux Commands Tutorials - Using the ls Command with Examples of Options - A Hands-On Tutorial Help

Linux Command Tutorials - Opening a Linux Terminal / Console to Run Linux Commands - Tutorial Help

How To Export A Microsoft Access Report as a PDF

About Winsock in Visual Basic.

15 Questions to ask your software vendor

Internet Explorer 7 (IE7) As a Ftp Client-Does Not Work

Windows Vista and Internet Explorer 7 Delete View Objects Bug

Home  |  Page Two  |  FAQ's  |  Contact  |  Terms of Service  |  Article Submission Guidelines  |  Writers' Contests  |  Privacy  |  Mission / About
Copyright © 1999-2008 SearchWarp.com, All Rights Reserved - SearchWarp.com is an IcoLogic, Inc. Company