Skip to content

EgorBot for xtqqczze in #108572 #113

Open
@EgorBot

Description

@EgorBot

Processing dotnet/runtime#108572 (comment) command:

Command

-mono -intel -arm64

using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

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

public class Benchmarks
{
    static bool[] _values = Enumerable.Range(0, 256).Select(i => i % 2 == 0).ToArray();
    static char[] _output = new char[4096];

    [Benchmark]
    public void WriteBools()
    {
        Span<char> output = _output;
        foreach (var value in _values)
        {
            if (value.TryFormat(output, out int written))
                output = output.Slice(written);
            else
                throw new InvalidOperationException();
        }

        Consume(output);
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    void Consume(Span<char> _){}
}

(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