Code Monkey home page Code Monkey logo

lastitembenchdemo's Introduction

.NET 5

LastItemBenchDemo

Benchmarking various ways to get last item from collection (list, array)

In this demo, i m using BenchmarkDotNet library in order to benchmark various ways of finding last item in a collection (list, array) :

1️⃣ Using linq

2️⃣ Using indexes

3️⃣ Using Ranges

In order to run benchmarks, type these commands in your favorite terminal :

✍️ .\App.exe --filter LastListItemBench

✍️ .\App.exe --filter LastArrayItemBench

|     Method |   Size |       Mean |     Error |    StdDev |        Min |        Max | Rank | Allocated |
|----------- |------- |-----------:|----------:|----------:|-----------:|-----------:|-----:|----------:|
| UsingRange |   1000 |  0.1868 ns | 0.0323 ns | 0.0302 ns |  0.1434 ns |  0.2393 ns |    1 |         - |
| UsingIndex |   1000 |  0.2807 ns | 0.0329 ns | 0.0308 ns |  0.2430 ns |  0.3423 ns |    2 |         - |
|  UsingLinq |   1000 | 22.9925 ns | 0.4925 ns | 0.5058 ns | 22.4384 ns | 24.1473 ns |    3 |         - |
|            |        |            |           |           |            |            |      |           |
| UsingRange |  10000 |  0.2131 ns | 0.0138 ns | 0.0129 ns |  0.1921 ns |  0.2282 ns |    1 |         - |
| UsingIndex |  10000 |  0.3064 ns | 0.0344 ns | 0.0460 ns |  0.2255 ns |  0.4187 ns |    2 |         - |
|  UsingLinq |  10000 | 23.5613 ns | 0.2234 ns | 0.2090 ns | 23.3008 ns | 23.9098 ns |    3 |         - |
|            |        |            |           |           |            |            |      |           |
| UsingIndex | 100000 |  0.1767 ns | 0.0127 ns | 0.0119 ns |  0.1504 ns |  0.1999 ns |    1 |         - |
| UsingRange | 100000 |  0.2450 ns | 0.0389 ns | 0.0382 ns |  0.2029 ns |  0.3349 ns |    2 |         - |
|  UsingLinq | 100000 | 22.9341 ns | 0.1171 ns | 0.0977 ns | 22.6640 ns | 23.0190 ns |    3 |         - |

Tools : vs19, net 5.0

lastitembenchdemo's People

Contributors

aimenux avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.