Tag Archives: performance

Compare the performance of simple arithmetic operations in C#

I saw a post the other day that said division was the slowest arithmetic operation so I wrote this example to see exactly how the performance of multiplication, division, addition, and subtraction differ with floating point numbers. When you click … Continue reading

Posted in mathematics, performance | Tagged , , , , , , , , , , , | 1 Comment

Compare the performance of the int, long, and byte data types in C#

The example Compare the performance of the float, double, and decimal data types in C# compares the performance of the float, double, and decimal data types. This example performs a similar test for the int, long, and byte data types. … Continue reading

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

Compare the performance of the float, double, and decimal data types in C#

A computer’s math coprocessor typically gives the best performance with a particular data type. To see which works best on my system and to learn how big the difference is, I wrote this program to compare the performance of calculations … Continue reading

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

Compare sorting algorithms in C#, article 5 of 5

Countingsort The discussion of Quicksort in my previous post mentions that the fastest possible sorting algorithms that use comparisons take on the order of N * log(N) steps. Countingsort does not use comparisons so it is not bound by that … Continue reading

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

Compare sorting algorithms in C#, part 3 of 5

Selectionsort Selectionsort is a very simple algorithm. First you search the list for the smallest item. Then you swap that item with the item at the top of the list. Next you find the second smallest item and swap it … Continue reading

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

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