jeme commented on PR #1108: URL: https://github.com/apache/lucenenet/pull/1108#issuecomment-2604201017
Interesting results, just scratching the surface hints that the J2N implementation is actually worse (and as such the Java implementation?), although for .NET 8 and 9 it may be within the margin for error: ``` BenchmarkDotNet v0.14.0, Windows 10 (10.0.19045.5131/22H2/2022Update) Intel Core i9-7900X CPU 3.30GHz (Kaby Lake), 1 CPU, 20 logical and 10 physical cores [Host] : .NET Framework 4.8.1 (4.8.9290.0), X64 RyuJIT VectorSize=256 DefaultJob : .NET Framework 4.8.1 (4.8.9290.0), X64 RyuJIT VectorSize=256 | Method | Mean | Error | StdDev | Gen0 | Allocated | |------------------ |-----------:|---------:|---------:|-------:|----------:| | BuiltInDictionary | 626.1 ns | 9.38 ns | 8.31 ns | 0.1183 | 746 B | | J2NDictionary | 2,764.5 ns | 22.97 ns | 21.49 ns | 0.1183 | 746 B | BenchmarkDotNet v0.14.0, Windows 10 (10.0.19045.5131/22H2/2022Update) Intel Core i9-7900X CPU 3.30GHz (Kaby Lake), 1 CPU, 20 logical and 10 physical cores .NET SDK 9.0.101 [Host] : .NET 8.0.11 (8.0.1124.51707), X64 RyuJIT AVX-512F+CD+BW+DQ+VL DefaultJob : .NET 8.0.11 (8.0.1124.51707), X64 RyuJIT AVX-512F+CD+BW+DQ+VL | Method | Mean | Error | StdDev | Gen0 | Allocated | |------------------ |---------:|--------:|--------:|-------:|----------:| | BuiltInDictionary | 344.1 ns | 5.10 ns | 4.77 ns | 0.1035 | 744 B | | J2NDictionary | 387.0 ns | 2.72 ns | 2.54 ns | 0.1035 | 744 B | BenchmarkDotNet v0.14.0, Windows 10 (10.0.19045.5131/22H2/2022Update) Intel Core i9-7900X CPU 3.30GHz (Kaby Lake), 1 CPU, 20 logical and 10 physical cores .NET SDK 9.0.101 [Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX-512F+CD+BW+DQ+VL DefaultJob : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX-512F+CD+BW+DQ+VL | Method | Mean | Error | StdDev | Gen0 | Allocated | |------------------ |---------:|--------:|--------:|-------:|----------:| | BuiltInDictionary | 333.7 ns | 3.74 ns | 3.50 ns | 0.1035 | 744 B | | J2NDictionary | 364.3 ns | 4.05 ns | 3.79 ns | 0.1035 | 744 B | ``` CSharp ``` using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Running; BenchmarkRunner.Run<DictionaryBenchmarks>(); [MemoryDiagnoser] public class DictionaryBenchmarks { [Benchmark] public byte BuiltInDictionary() { Dictionary<byte, byte> values = new (); AddItems(values); byte x = 0; foreach (byte b in values.Values.ToArray()) { values.Remove(b); x += b; } return x; } [Benchmark] public int J2NDictionary() { J2N.Collections.Generic.Dictionary<byte, byte> values = new(); AddItems(values); byte x = 0; foreach (byte b in values.Values) { values.Remove(b); x += b; } return x; } private void AddItems(IDictionary<byte,byte> x) { x.Add(0, 0); x.Add(1, 1); x.Add(2, 2); x.Add(3, 3); x.Add(4, 4); x.Add(5, 5); x.Add(6, 6); x.Add(7, 7); x.Add(8, 8); x.Add(9, 9); x.Add(10, 10); x.Add(11, 11); x.Add(12, 12); x.Add(13, 13); x.Add(14, 14); x.Add(15, 15); } } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org