.NET news » Search results

Search results for query "line count" (6):

Performance Quiz #9 : IList<T> List and array speed

A short and sweet quiz with lots of juicy discussion possibilities:

public int Sum(IList<ushort> indices)
{
int result = 0;
for (int i = 0; i < indices.Count; i++)
result += indices[i];
return result;
}

Considering only the time it takes to do the Sum (i.e. assuming we had already set up the array/list) which gives better performance and why?

// #1
ushort[] tmp = new ushort[500000]; // this doesn't count
Sum(tmp);// this is what we are timing

OR

// #2
List<ushort> tmp = new List<ushort>(500000); // this doesn't count
for (int i = 0; i < 500000; i++)tmp.Add(0); // this doesn't count
Sum(tmp); // this is what we are timing

What say you gentle readers?

2006-03-09 18:31:00   Source: Performance Quiz #9 : IList<T> List and array speed   Tags: Performance C#

System.Diagnostics.Stopwatch - always remember to use Reset

Wrong
        System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch();

        s.Start();
        for (i = 0; i  count; i++) Test1();
        s.Stop();
        Console.WriteLine("Test1: {0}", s.ElapsedMilliseconds);

        s.Start();
        for (i = 0; i  count; i++) Test2();
        s.Stop();

        Console.WriteLine("Test2: {0}", s.ElapsedMilliseconds);
Right
        System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch();

        s.Start();
        for (i = 0; i  count; i++) Test1();
        s.Stop();
        Console.WriteLine("Test1: {0}", s.ElapsedMilliseconds);

        s.Reset();

        s.Start();
        for (i = 0; i  count; i++) Test2();
        s.Stop();

        Console.WriteLine("Test2: {0}", s.ElapsedMilliseconds);
Not that *cough* I would ever make this mistake or anything, but you know... it could happen to like, a friend, or something. Ya. My friend. :)

Line Counter - Writing a Visual Studio 2005 Add-In

Provides complete Solution and Project line counting and summary tool, written as a Visual Studio 2005 Managed Add-In (C#).

Create Dynamic XAML Forms with the Presentation Model Pattern

This article presents an advanced technique that lets you bind multiple editable line items to a collection using Windows Presentation Foundation and the Presentation Model pattern. It assumes you are familiar with basic WPF data binding techniques as well as design patterns that object-oriented UI libraries typically use. After an introduction to the sample application used throughout this article, you'll see how applying the Presentation Model pattern insulates this application's UI and business logic layers from one another. Finally, you'll see the WPF-specific details involved in binding a Presentation Model to XAML controls to create a dynamic UI with multiple editable line items.
2007-08-10 15:04:44   Source: Create Dynamic XAML Forms with the Presentation Model...   Tags: GUI XML

Access image metadata using Visual Studio's new object data binding feature

Using a new class library to bind to photo metadata with a few line of code.

Line Counter - Writing a SharpDevelop AddIn

This article shows you how to start writing SharpDevelop AddIns by porting Jon Rista's VS AddIn to SharpDevelop
2006-07-18 12:49:00   Source: Line Counter - Writing a SharpDevelop AddIn   Tags: Addins
1