Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EgorBot for PranavSenthilnathan in #111824 #263

Open
EgorBot opened this issue Jan 26, 2025 · 1 comment
Open

EgorBot for PranavSenthilnathan in #111824 #263

EgorBot opened this issue Jan 26, 2025 · 1 comment

Comments

@EgorBot
Copy link
Owner

EgorBot commented Jan 26, 2025

Processing dotnet/runtime#111824 (comment) command:

Command

-intel -profiler -commit main --envvars DOTNET_JitDisasm:Vector DOTNET_EnableAVX512F:0

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

// Actual runner is optional, but if it exists, it has to be like this:
BenchmarkSwitcher.FromAssembly(typeof(Bench).Assembly).Run(args);

public class Bench
{
    public int size = 512;

    public string encName = "utf-8";
    private Encoding _enc;
    private string _toEncode;
    private char[] _chars;
    [GlobalSetup]
    public void SetupGetBytes()
    {
        _enc = Encoding.GetEncoding(encName);
        _toEncode = CreateString(size);
        _chars = _toEncode.ToCharArray();
    }

    [Benchmark]
    [MemoryRandomization]
    public int GetByteCount() => _enc.GetByteCount(_chars);

    public static string CreateString(int length)
    {
        char[] str = new char[length];

        for (int i = 0; i < str.Length; i++)
        {
            // Add path separator so folders aren't too long.
            if (i % 20 == 0)
            {
                str[i] = Path.DirectorySeparatorChar;
            }
            else
            {
                str[i] = 'a';
            }
        }

        return new string(str);
    }
}

(EgorBot will reply in this issue)

@EgorBot
Copy link
Owner Author

EgorBot commented Jan 26, 2025

Benchmark results on linux_azure_cascadelake

BenchmarkDotNet v0.14.0, Ubuntu 24.04.1 LTS (Noble Numbat)
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 8 logical and 4 physical cores
  Job-ARUYEF : .NET 10.0.0 (42.42.42.42424), X64 RyuJIT AVX2
Job=Job-ARUYEF  OutlierMode=DontRemove  EnvironmentVariables=DOTNET_JitDisasm=*Vector*,DOTNET_EnableAVX512F=0
Toolchain=CoreRun  MemoryRandomization=True  StdDev=0.597 ns
Method Mean Error
GetByteCount 25.42 ns 0.537 ns

BDN_Artifacts.zip

Profiling for Bench_GetByteCount:

SVG flamegraph: Main 🔥
Speedscope flamegraph: Main
Hot asm code: Main
HW counters: Main


cc @PranavSenthilnathan (agent_logs.txt). EgorBot manual: link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant