csharpc

System.Collections.ObjectModel (CoreLib types)

A library or CoreLib type served from the framework’s IL: its row of the per-library table of ADR 0023 (columns explained there, under “Measurements”). These are the ObjectModel types System.Private.CoreLib defines; ObservableCollection<T> and the rest of the System.ObjectModel assembly are in System.ObjectModel.md.

Library (switch) Correctness (samples from IL) Binary size, IL / shadow Compile cpu, IL / shadow Speed, IL / shadow (time) Lines removed on a flip Decision NativeAOT on the same host, csharpc / NativeAOT (tools/il-first/measure-aot.sh: stripped size; compile cpu; run, median of 7; instructions)
System.Collections.ObjectModel.Collection<T>, ReadOnlyCollection<T>, ReadOnlyDictionary<TKey,TValue> (+ its key, value and enumerator types) (src/Csharpc/upstream-types/System.Collections.ObjectModel.txt, CoreLib types: the slicer route) the same 104 samples as System.Collections.Generic.Queue.md (22 of them use these types: 501, 1060, 380, 610, 647, the JSON and LINQ samples…) byte-identical to real .NET at -O0 and -O2, and via IL with the same pre-existing exception (1160, #376) objectmodel_corelib_throughput 179 272 to 179 544 B (1.00x) 4.6 to 4.7 s objectmodel_corelib_throughput (20 rounds: Collection<int> 500 k Add, indexer, 1 000 Insert(0)/RemoveAt; ReadOnlyCollection<int> indexer, foreach, IndexOf; ReadOnlyDictionary<int,int> 1 M TryGetValue, enumeration, Keys): instructions 10 188 M to 10 204 M (1.00x); median of 5 1 258 to 1 477 ms (noise: the instruction counts are equal) 384 (corelib/Collection.cs 190, corelib/ObjectModel.cs 110, corelib/ReadOnlyDictionary.cs 84) Flipped (#367): same speed and size, and the framework’s own argument checks, exception texts and IList/ICollection behaviour instead of three hand-written shadows. objectmodel_corelib_throughput: 179 368 / 1 392 192 B; compile cpu 4.6 / 13.3 s; run 1 597 / 1 568 ms (1.02x); 10.2 G / 8.4 G instructions (the shadow’s count was the same, 10.19 G)