Benchmarking experiment 4

How much time it takes to insert a single element in a random location in a list-based collection?

Sometimes we need to insert an element at a random location. Think about sorting, for example. Not all collections are geared to make this efficient. However, I shall benchmark the containers that support this operation:

List<T>
LinkedList<T>
C5.HashedLinkedList<T>
C5.HashedArrayList<T>
C5.LinkedList<T>
C5.ArrayList<T>

Apart from LinkedList<T> in the System.Collections.Generic namespace, all other containers listed previously have a method called insert() to insert an element at the mentioned index:

using System; using SCG = System.Collections.Generic; using System.Linq; using System.Text; using C5; namespace PerformanceMap ...

Get .NET 4.0 Generics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.