Skip to content

Benchmarks for #123027 (EgorBo) #585

@EgorBot

Description

@EgorBot

Processing dotnet/runtime#123027 (comment) command:

Command

-intel -arm -windows_intel -amd --runtimes net8.0 net10.0 --envvars DOTNET_JitDisasm:Iterate_With_Span

using BenchmarkDotNet.Attributes;
using System;
using BenchmarkDotNet.Running;

BenchmarkSwitcher.FromAssembly(typeof(Benchmarks).Assembly).Run(args);

[MemoryDiagnoser]
public class Benchmarks
{
    const int N = 1000000;
    float[] _data;

    [GlobalSetup]
    public void Setup()
    {
        _data = new float[N];
        for (int i = 0; i < N; i++) _data[i] = 1;
    }

    [Benchmark]
    public double Iterate_With_Span()
    {
        double result = 0;
        Span<float> span = _data;

        for (int i = 0; i < N; i++)
        {
            result += span[i];
        }

        return result;
    }
}

(EgorBot will reply in this issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions