Giter Club home page Giter Club logo

arraypoolallocationreproduce's Introduction

Reproduce for ArrayPool allocations

Comparing using ArrayPool.Shared and instance created with ArrayPool.Create.

private static readonly ArrayPool<Vector2> CreatedPool = ArrayPool<Vector2>.Create(Settings.StepsCount, 4000);

public static ArrayPool<Vector2> GetPool()
{
    if (UseShared)
        return ArrayPool<Vector2>.Shared;

    return CreatedPool;
}

Code in main is look like this:

Execute();
AllocationMode.UseShared = false;
Execute();

Benchmark

BenchmarkDotNet=v0.13.1, OS=Windows 10.0.22000 AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores .NET SDK=7.0.100-preview.4.22252.9 [Host] : .NET 6.0.5 (6.0.522.21309), X64 RyuJIT DefaultJob : .NET 6.0.5 (6.0.522.21309), X64 RyuJIT

Method UseShared Mean Error StdDev Gen 0 Gen 1 Allocated
Read False 274.1 ms 4.16 ms 5.96 ms - - 5 MB
Read True 292.4 ms 4.52 ms 3.78 ms 4000.0000 2000.0000 39 MB

dotMemory

DotMemory trace with changing allocation mode:

Allocated objects while we using ArrayPool<Vector2>.Shared:

Allocated objects while we using pool form ArrayPool<Vector2>.Create:

arraypoolallocationreproduce's People

Contributors

fredikats avatar

Watchers

 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.