Free Online Articles Directory
18.11.2008 Sign In Register Hello Guest
Email:
Password:
Remember Me 
forgot your password?


Testing C# Code Performance Speed

Author: VCkicks Author Ranking Blue | Posted: 26-06-2008 | Views: 29 | Rating:  (57) Article Popularity - Blue (?) Got a Question? Ask.
Sign Up Now!

Programming with C#, as in a lot of languages, gives an infinite amount of ways to write applications. All the different programming pratices can vary your application's speed and efficiency. Determening which coding techniques are faster is an essential skill.

The algorithm to test out fast and efficient C# source code run is:

-> Initialize variables needed

-> Declare a System.Diagonistic.StopWatch varible.

-> Include this line before starting the test: [StopWatch variable].Start();

-> Setup a for loop with the code to be tested inside

-> The amount of trials should be set up in such a way that the total execute time lasts an appropriate duration

-> Execute this line to stop the StopWatch: [StopWatch variable].Stop();

-> Initialize a new TimeSpan variable with: TimeSpan span = new TimeSpan([StopWatch variable].ElapsedTicks);

-> The span variable has the amount of time the source took to run

An optional part is to divide the time it took to execute the C# code and divide it by the amount of times the for loop ran. Giving you the average time per call.

I myself like to compare the total execution time because it has less chance of variation in the results.

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

Additionally I recommend to test source code from within Visual Studio since source code that runs with the debugger runs a bit slower. Creating a nicer window of time to compare different snippets of source code.

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

You can download a free C# Example Utility that uses the algorithm described at => http://vckicks.110mb.com/code_speed_test.html

Also for general tips on optimizing C# code visit => http://vckicks.110mb.com/optimize_csharp_code.html for 5 ways to quickly improve your C#.Net code.

Rate this Article: Current: 0 / 5 stars - 0 vote(s).

Article Source: http://www.articlesbase.com/programming-articles/testing-c-code-performance-speed-463307.html

Print this Article Print article   Email to a Friend Send to friend   Publish this Article on your Website Publish this Article   Send Author Feedback Author feedback  
About the Author:

Visual C# Kicks - The place for high quality C# articles

Submitting articles has become one of the most popular means to drive traffic to your website and promote yourself and your business. Join us today - It's Free!

Related Articles

How to Solve a Common Problem With Asp.net Formview Defaultstate Property
By: Leonardo Paneque | 29/10/2007 | Programming
Describes how to use the FormView's DefaultState property to avoid problems.

Search Engine Optimization For Google
By: David Bell | 25/10/2005 | SEO
Expert Google search engine optimization have increased exponentially, because of the proven search engine optimization and search engine positioning techniques.

What Does A Blogging Consultant Look Like?
By: Chris Mcelroy Aka Namecritic | 02/06/2006 | Affiliate Programs
You know, normally you can find a definition of a word or phrase by typing "define: your phrase here" into google and come up with a lot of results.

Optimizing a Sales Page for Search Engines
By: George Christodoulou | 09/10/2006 | Marketing
Join This "Exclusive service" that will amazingly write a blog for you every day, write 3 articles and 1 press release while still increasing links to your site, all in one amazing service. Imagine all of this in a Secret blogging service at internetbusiness-tips.com

Web Promotion
By: Dragos Diaconescu | 05/12/2006 | Internet
The Web Marketing services are an essential necessity for any business presented on the Internet. The most important thing is to choose a correct marketing policy, and the results will appear immediately. There are some extremely efficient methods to promote your products or services.

What is Affiliate Marketing ?
By: Vicki Churchill | 15/01/2007 | Affiliate Programs
Choosing a product can take some time, you need to choose a product that your visitors are actually going to be interested in. If your own site sells pet food there is no point sending your visitors to a pet food shop that sells its products for less, you will simply lose customers.

Enhance your Website to Keep your Visitors Stay Longer
By: Isaac Chu | 07/05/2007 | Online Promotion
Building the web site is just a starting point, you need to submit your website to search engines and directories. You also need to keep your visitors stay longer and browse your website.

Focus Your SEO Efforts On Google And The Rest Will Follow
By: Gary Ruplinger | 18/05/2007 | Internet
When optimizing your website for the search engines, you really have three choices on which one to optimize for - Google, Yahoo, or MSN. Each search engine has certain criteria that is emphasized more and the factors that help you rank well differ from search engine to search engine. For...

Got a Question? Ask.

Ask the community a question about this article:

Frequently Asked Questions

Red squares over webpage advertisements
By: Nicole | 17-10-2008
I keep seeing red squares/blocks over webpage advertisements when I'm online. I think this is some kind of spyware, adware, malware or other harmful bug on my computer. Has anyone else ever had this problem? If so, what is causing this problem?

Database programmer
By: Ryan | 17-10-2008
what is it like being a database programmer?

What encoder works with Flash 6?
By: cahanckgraphics | 17-10-2008
What encoder works with Flash 6?

What is the keygen of Nero-6.6.0.8a?
By: akshar | 17-10-2008
what is the keygen of Nero-6.6.0.8a?

I have forgotten my phone lock code on the main ...
By: charlee | 16-10-2008
i have forgotten my phone lock code on the main settings! this is not a pin! What do i do?

Please Suggest Some?
By: nelson | 16-10-2008
I?ve been using a test management tool for quite some time but it has not lived up to the expectations. So I?m planning to invest in a good one. Please suggest some?

Q&A Powered by:
Powered by Yedda 

Latest Programming Articles

Cool Desktop Wallpapers
By: Danny | 18/11/2008
Cool desktop wallpaper is accomplishments arrangement that displayed in the computer operating system. The wallpapers usually be acclimated in JPEG, BMP and GIF book formats. That wallpaper can be acclimated with Microsoft Windows, Linux and Macintosh Mac OS. Each adviser can be altered requirements, alike admitting wallpaper images advised for accepted monitors can be scaled up or bottomward to the fit size. Those are accessible on the internet for free. Some categories of wallpapers are a

Tips for Buying Software Online
By: Daniel Jowssey | 17/11/2008
Buying software online not only helps save the planet, it also has other benefits, including: * Ease and Simplicity. You can purchase software in your underwear at 4am if you really want to. Shopping online doesn’t have to be done within regular business hours, nor do you need to look your best to do it. It’s also easy to shop around for the best prices and takes less time than driving to the shops.

Mvc Design Pattern
By: TuVinhSoft .,JSC | 14/11/2008
Model-view-controller (MVC) is an architectural pattern used in software engineering. In complex computer applications that present a large amount of data to the user, a developer often wishes to separate data (model) and user interface (View) concerns, so that changes to the user interface will not affect data handling, and that the data can be reorganized without changing the user interface.

Advantages of Low Cost Contract Programmers in Freelance Programming
By: Joanna Gadel | 12/11/2008
It observed that web industry is getting tougher thus the necessity of freelance contract programmer is required for developing more effective website with flexible features. This article states the fruitful advantages of freelance programmers in contract programming.

A Guide to Cnc Kits
By: Martin Applebaum | 09/11/2008
CNC kits are a way in which to construct your CNC machine. This article will provide some information on these machines.

A Guide to Cnc Tube Bending Machines
By: Martin Applebaum | 08/11/2008
Are you familiar with a CNC tube bending machine? This article will shed some light on the main function and components of this machine.

Ways to Hire Dedicated Php Programmers
By: Jucick | 08/11/2008
It’s not at all easy to hire dedicated PHP programmers unless you know where and how to find them. Whether you need to fix, update or enhance your website you naturally want the job done quick and right.

Top 4 Reasons Why Addressing Web Accessibility is Important
By: Matt Cave | 05/11/2008
There are very high chances that web accessibility is more important to the performance of your web site than you realize. Article takes a look at the top 4 reasons why it would be important to address the issue of web accessibility.

More from VCkicks

Use Colored Links With Adsense
By: VCkicks | 17/08/2008 | PPC Advertising
Consider the option of color-links in AdSense units to increase click-through ratio (CTR). There are some cases in which non-blue links will dramatically boost your earnings.

Obfuscate Source Code - Protect C# Applications
By: VCkicks | 25/07/2008 | Software
Due to the way C# programs are compiled, their source code is vulnerable. C# decompilers can access an executable file and read all the original source code, intact except for comments.

Make More Sales on Ebay - Simple Image Trick
By: VCkicks | 25/07/2008 | Online Business
Making your eBay products look appealing is essential to fetching high auction prices on eBay listings. But just as important is creating an appealing auction page overall. Here's a simple trick to catch buyer's attention

Profiting From the Ebay Shopper Mindset
By: VCkicks | 23/07/2008 | Online Business
Most eBay shoppers are buying online for one of two reasons: eBay offers a particular item not found anywhere else, or eBay offers the potential getting more value for your money. That second reason in particular is a gold mine just waiting to be mined.

Ebay Smart Shipping Pricing
By: VCkicks | 22/07/2008 | Online Business
Shipping and handling is not a place for your eBay business to make money. It is a common mistake to attempt to boost profits by artificially increasing the price of shipping a product.

Three Ways to Shorten Affiliate Links With Free Software
By: VCkicks | 15/03/2008 | Affiliate Programs
A url cloaker is a small program that automatically creates an html (or php) page to redirect links. Such pratices are popular among affiliates, where protecting links and making them look professional is vital. There are numerous ways to protect affiliate links, but here we will cover the three most popular and convenient.

Article Categories





Give Feedback

Sign up for our email newsletter

Receive updates, enter your email below