Category Archives: performance

Compare sorting algorithms in C#, part 2 of 5

Bubblesort Bubblesort is a specialized algorithm designed for sorting items that are already mostly in sorted order. If only one or two items in your list are out of order, Bubblesort is very fast. If the items in your list … Continue reading

Posted in algorithms, performance | Tagged , , , , , , , , , , , , , , | Leave a comment

Compare sorting algorithms in C#, post 1 of 5

This post begins a series of articles about sorting algorithms. Much of the text originally appeared in the December 1995 issue of Visual Basic Developer magazine, a publication that seems to no longer exist. All of these posts include the … Continue reading

Posted in algorithms, performance | Tagged , , , , , , , , , , , , , , | 6 Comments

Compare the performance of incrementing statements in C#

This is another performance testing post. Assembly language usually has statements comparable to x++, x–, x +=, and other operators that add or subtract to a value and store the result in the same value, so it makes some sense … Continue reading

Posted in performance, syntax | Tagged , , , , , , , , , | Leave a comment

Compare the performance of string comparison methods in C#

This example uses the following code to make four strings: string value0 = “AAAAAAAAAAAAAAAAAAAAAA”; string value1 = “AAAAAAAAAAAAAAAAAAAAAA”; string value2 = “AAAAAAAAAAAAAAAAAAAAAB”; string value3 = “BAAAAAAAAAAAAAAAAAAAAA”; It then uses several methods for comparing the first string with the others. For … Continue reading

Posted in performance, strings | Tagged , , , , , , , , , | Leave a comment

Compare the performance of switch and if statements in C#

This example compares the performance of switch and if-else statements. Both do roughly the same thing: they check a series of conditions until they find one that is true and then skip the rest. This example compares the speeds of … Continue reading

Posted in performance, syntax | Tagged , , , , , , , , , , , , , , | Leave a comment

Compare loop performance in C#

The Code Project post FOREACH Vs. FOR (C#) examines the IL code created for a C# foreach loop and a for loop to compare loop performance. The author notices some unnecessary statements in the foreach loop and therefore concludes that … Continue reading

Posted in performance, syntax | Tagged , , , , , , , , , , , | Leave a comment

Study WPF 3D performance in C#

The example Make a stellate geodesic sphere with WPF and C# makes a pretty complicated shape so I was wondering about the performance provided by WPF 3D programs. This example makes a group of stellate spheres using WPF 3D. See … Continue reading

Posted in animation, graphics, mathematics, performance, wpf | Tagged , , , , , , , , , , , , | 1 Comment

Compare the performance of if-else and switch statements in C#

The example Compare the speeds of the conditional operator (ternary operator ?:) and the if-else statement in C# compares the performance of two kinds of conditional tests. Johnny Boy pointed out that this didn’t include another kind of conditional statement: … Continue reading

Posted in performance, syntax | Tagged , , , , , , , , , , , , , , | Leave a comment

Compare the speeds of the conditional operator (ternary operator ?:) and the if-else statement in C#

The conditional operator (also called the ternary operator) looks confusing enough that some programmers assume it must be more efficient than a comparable but longer if-else statement. This example uses the following code to compare the speeds of the conditional … Continue reading

Posted in performance, syntax | Tagged , , , , , , , , , , | 5 Comments

Make a class that wraps arrays with non-zero lower bounds in C#

The example Make arrays with non-zero lower bounds in C# shows how to use the Array class to make an array with non-zero lower bounds. Unfortunately the syntax is unnatural, requiring you to use method calls instead of normal array … Continue reading

Posted in arrays, performance, variables | Tagged , , , , , , , , , , , , | Leave a comment