Click here to Skip to main content
15,885,767 members
Articles / Programming Languages / C#
Tip/Trick

Are Speed Considerations Concerning List Still Important (Performance of Loyc's AList<T>)?

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
11 Feb 2019CPOL2 min read 6.4K   2
Compare the speed of generic collections running on .NET Framework 4.6.1, .NET Core 2.1 and Mono/.NET 4.5 based on the framework's version of List against Loys's version of AList.

Introduction

Recently, I was looking for a fast list and stumbled upon Loyc's AList<T>.

The AList<T> is part of a bunch of generic collection classes, that have been introduced here at Code Project already by Qwertie. In this tip, you'll find a simple comparison of performance, which I have missed in the original article.

Background

The generic collection classes of the .NET standard library do a very good job, especially:

  • for small and medium size collections and
  • primarily for element read access and append operations

Conversely, they tend to be less suitable:

  • for large lists and
  • insert-at or remove-at (random access) operations

Let's take a look at the performance...

Using the Code

I have prepared three solutions (.NET Framework 4.6, .NET Core 2.1 and Mono/.NET 4.5) with exactly the same test case - random access insert-at and delete-at operations. This is the only scenario, that is worth inspecting - in all other cases, the .NET standard library is the best choice.

Loyc's AList<T> is available as NuGet package, compiled for 'Any CPU' targeting .NET 4.5, and source code at GitHub, that supports multiple targets: ,NET 3.5, .NET 4.0 and .NET 4.5.

It is easy to integrate the NuGet packages into the .NET Framework 4.6.1 and the Mono/.NET 4.5 projects. To get Loyc's AList<T> running for .NET Core 2.1, I had to adopt the source code - but this was done in less than 10 minutes as well.

The performance comparison (linear scale - to get an impression of the difference between best and worst):

Image 1

The performance comparison (logarithmic scale - to display even the small figures):

Image 2

The raw figures:

Image 3

How it looks running on Mono/.NET 4.5 (I've used VMWare Player 12.5.9 to run an openSUSE 13.3 64 Bit with 4GB RAM and 2 cores on an Intel(R) Core(TM) i7-5600U CPU):

Image 4

How it looks running on .NET Framework 4.6.1 (I've used the same Intel(R) Core(TM) i7-5600U CPU):

Image 5

How it looks running on .NET Core 2.1 (I've used the same Intel(R) Core(TM) i7-5600U CPU):

Image 6

The Quintessence

  • Mono/.NET4.5 is the slowest environment for large list. Loyc performs very well in this scenario and is a good alternative.
  • .NET Core 2.1 outperforms Loyc.
  • .NET Framework 4.6.1 is better than Mono/.NET4.5 and worse than .NET Core 2.1. Loyc performs very well in this scenario and is a good alternative.

History

  • 11th February, 2019: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader Celonis SA
Germany Germany
I am currently the CEO of Symbioworld GmbH and as such responsible for personnel management, information security, data protection and certifications. Furthermore, as a senior programmer, I am responsible for the automatic layout engine, the simulation (Activity Based Costing), the automatic creation of Word/RTF reports and the data transformation in complex migration projects.

The main focus of my work as a programmer is the development of Microsoft Azure Services using C# and Visual Studio.

Privately, I am interested in C++ and Linux in addition to C#. I like the approach of open source software and like to support OSS with own contributions.

Comments and Discussions

 
QuestionScales of the graphs are not clearly labeled Pin
markchagers12-Feb-19 20:57
markchagers12-Feb-19 20:57 
QuestionThe URL link is missing Pin
Fanliver11-Feb-19 16:41
Fanliver11-Feb-19 16:41 
The AList<T> is part of a bunch of generic collection classes, that have been introduced here at CODE PROJECT 

The URL link in introduced here is incorrect. Please update it.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.