EgorBot / runtime-utils

MIT License
0 stars 1 forks source link

EgorBot for EgorBo in #109077 #130

Open EgorBot opened 1 month ago

EgorBot commented 1 month ago

Processing https://github.com/dotnet/runtime/issues/109077#issuecomment-2427172652 command:

Command -arm64 -amd --runtimes net8.0 net9.0 ```cs using System.Runtime.CompilerServices; using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Running; using System.Collections.Generic; using System.Collections; public class MyClass {} public class Bench { object _obj = new MyClass[2]; [Benchmark] public int IsCollection() => _obj is ICollection coll ? coll.Count : 0; [Benchmark] public int IsCollection_expected() { var obj = _obj; if (obj is MyClass[]) return Unsafe.As(ref obj).Length; return 0; } } ```

(EgorBot will reply in this issue)

EgorBot commented 1 month ago

Benchmark results on Amd

BenchmarkDotNet v0.14.0, Ubuntu 24.04 LTS (Noble Numbat)
AMD EPYC 9R14, 1 CPU, 4 logical and 4 physical cores
  Job-HZMTFC : .NET 8.0.10 (8.0.1024.46610), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  Job-TUJIVI : .NET 9.0.0 (9.0.24.47305), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
Method Runtime Mean Error Ratio
IsCollection .NET 8.0 4.7780 ns 0.0190 ns 1.00
IsCollection .NET 9.0 1.8073 ns 0.0189 ns 0.38
IsCollection_expected .NET 8.0 1.3686 ns 0.0063 ns 1.00
IsCollection_expected .NET 9.0 0.2773 ns 0.0035 ns 0.20

BDN_Artifacts.zip

EgorBot commented 1 month ago

cc @EgorBo (logs)

EgorBot commented 1 month ago

Benchmark results on Arm64

BenchmarkDotNet v0.14.0, Ubuntu 24.04 LTS (Noble Numbat)
Arm64
  Job-QVXRWJ : .NET 8.0.10 (8.0.1024.46610), Arm64 RyuJIT AdvSIMD
  Job-GAOKJD : .NET 9.0.0 (9.0.24.47305), Arm64 RyuJIT AdvSIMD
Method Runtime Mean Error Ratio
IsCollection .NET 8.0 7.6679 ns 0.0022 ns 1.00
IsCollection .NET 9.0 1.1448 ns 0.0001 ns 0.15
IsCollection_expected .NET 8.0 0.0814 ns 0.0002 ns 1.000
IsCollection_expected .NET 9.0 0.0000 ns 0.0000 ns 0.000

BDN_Artifacts.zip

EgorBot commented 1 month ago

cc @EgorBo (logs)