Benchmark of Collection Initializing in terms of Execution Time (Mean)


BenchmarkDotNet v0.13.11, Windows 11 (10.0.22631.2861/23H2/2023Update/SunValley3)
AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores
.NET SDK 8.0.100
  [Host]   : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
  ShortRun : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2

Job=ShortRun  IterationCount=3  LaunchCount=1  
WarmupCount=3

Comparison: Mean

MethodLengthSortedInt32StringStructIntsClassIntsRecordStructIntsRecordClassIntsStructStringsClassStringsRecordStructStringsRecordClassStrings
Array 10000 False 2.020 μs 3.082 μs 49.54 μs 3.529 μs 48.85 μs 3.285 μs 111.9 μs 3.454 μs 109.1 μs 3.349 μs
ReadOnlyCollection 10000 False 2.065 μs 3.264 μs 52.25 μs 3.492 μs 49.46 μs 3.233 μs 110.8 μs 3.660 μs 109.8 μs 3.355 μs
ImmutableArray 10000 False 2.125 μs 3.509 μs 49.57 μs 3.551 μs 49.25 μs 3.366 μs 107.2 μs 3.346 μs 111.2 μs 3.350 μs
List 10000 False 2.247 μs 3.441 μs 49.78 μs 3.688 μs 48.78 μs 3.922 μs 109.9 μs 3.129 μs 111.2 μs 3.877 μs
LinkedList 10000 False 114.877 μs 132.915 μs 127.29 μs 129.972 μs 122.81 μs 135.016 μs 158.3 μs 133.071 μs 157.4 μs 132.172 μs
ImmutableList 10000 False 116.774 μs 168.067 μs 122.48 μs 170.240 μs 122.80 μs 167.254 μs 212.7 μs 170.977 μs 210.7 μs 171.943 μs
Dictionary 10000 False 140.964 μs 265.932 μs 399.97 μs 255.905 μs 280.11 μs 273.141 μs 1,023.8 μs 521.498 μs 638.9 μs 527.394 μs
ReadOnlyDictionary 10000 False 143.362 μs 274.805 μs 404.26 μs 256.470 μs 277.06 μs 284.909 μs 1,018.5 μs 519.752 μs 674.7 μs 566.916 μs
HashSet 10000 False 148.196 μs 241.259 μs 372.90 μs 226.485 μs 197.72 μs 248.790 μs 948.9 μs 498.867 μs 598.2 μs 493.711 μs
Array (Sorted) 10000 False 324.932 μs 5,156.343 μs 478.77 μs 747.774 μs 487.19 μs 781.367 μs 5,916.1 μs 5,754.522 μs 5,979.4 μs 5,710.599 μs
List (Sorted) 10000 False 326.058 μs 5,106.965 μs 480.98 μs 754.041 μs 503.64 μs 790.429 μs 6,068.8 μs 5,844.496 μs 5,895.5 μs 5,731.839 μs
ImmutableArray (Sorted) 10000 False 326.504 μs 5,192.886 μs 495.91 μs 747.096 μs 489.48 μs 747.232 μs 6,239.0 μs 5,723.010 μs 6,083.9 μs 5,707.202 μs
FrozenSet 10000 False 407.216 μs 1,432.992 μs 920.72 μs 643.034 μs 605.76 μs 689.554 μs 2,043.1 μs 1,155.110 μs 1,231.4 μs 1,205.622 μs
SortedSet 10000 False 414.855 μs 5,684.240 μs 607.60 μs 885.444 μs 615.15 μs 855.998 μs 6,563.2 μs 6,252.427 μs 6,691.2 μs 6,403.660 μs
FrozenDictionary 10000 False 444.312 μs 1,328.777 μs 874.80 μs 756.472 μs 621.41 μs 800.424 μs 2,052.6 μs 1,242.227 μs 1,257.2 μs 1,323.209 μs
ImmutableSortedSet 10000 False 456.041 μs 5,760.166 μs 650.17 μs 971.541 μs 652.53 μs 1,024.883 μs 7,287.7 μs 6,342.280 μs 6,563.3 μs 6,496.165 μs
SortedList 10000 False 628.833 μs 6,016.551 μs 974.07 μs 1,190.681 μs 956.76 μs 1,214.383 μs 7,631.9 μs 6,857.941 μs 7,527.8 μs 7,006.464 μs
ImmutableList (Sorted) 10000 False 654.541 μs 5,806.514 μs 869.22 μs 1,403.213 μs 853.70 μs 1,388.404 μs 6,757.5 μs 6,387.129 μs 6,701.1 μs 6,517.718 μs
SortedDictionary 10000 False 1,289.650 μs 6,019.642 μs 1,629.18 μs 2,217.730 μs 1,526.66 μs 2,270.468 μs 6,509.8 μs 6,724.190 μs 6,330.0 μs 6,712.728 μs
ImmutableSortedDictionary 10000 False 1,953.540 μs 11,013.998 μs 2,547.80 μs 3,654.423 μs 2,613.99 μs 3,719.728 μs 11,453.6 μs 11,775.346 μs 11,672.2 μs 11,810.306 μs
ImmutableHashSet 10000 False 1,979.512 μs 2,544.854 μs 2,490.51 μs 2,738.551 μs 2,263.04 μs 2,593.169 μs 3,093.5 μs 2,784.962 μs 2,697.5 μs 2,805.189 μs
ImmutableDictionary 10000 False 2,228.753 μs 2,632.661 μs 2,677.68 μs 2,612.836 μs 2,376.88 μs 2,650.795 μs 3,957.3 μs 3,038.927 μs 2,891.3 μs 2,898.711 μs
MethodLengthSortedInt32StringStructIntsClassIntsRecordStructIntsRecordClassIntsStructStringsClassStringsRecordStructStringsRecordClassStrings
Array 10000 True 1.849 μs 3.384 μs 49.98 μs 4.005 μs 50.55 μs 3.187 μs 110.6 μs 3.588 μs 109.4 μs 3.254 μs
ReadOnlyCollection 10000 True 1.950 μs 3.469 μs 49.92 μs 3.607 μs 48.99 μs 3.843 μs 110.3 μs 3.778 μs 110.5 μs 3.536 μs
ImmutableArray 10000 True 2.096 μs 3.508 μs 49.59 μs 3.451 μs 49.22 μs 3.331 μs 108.4 μs 3.579 μs 108.5 μs 2.981 μs
List 10000 True 2.301 μs 3.390 μs 48.99 μs 3.547 μs 49.33 μs 4.048 μs 110.0 μs 2.976 μs 111.0 μs 3.345 μs
ImmutableArray (Sorted) 10000 True 8.295 μs 434.603 μs 61.10 μs 43.909 μs 59.56 μs 42.374 μs 552.4 μs 526.995 μs 558.7 μs 507.635 μs
Array (Sorted) 10000 True 40.223 μs 3,506.397 μs 141.70 μs 272.357 μs 142.19 μs 275.517 μs 3,726.6 μs 3,855.092 μs 3,723.7 μs 4,078.451 μs
List (Sorted) 10000 True 40.531 μs 3,529.088 μs 142.81 μs 258.926 μs 142.27 μs 271.843 μs 3,702.6 μs 3,806.999 μs 3,816.7 μs 3,899.622 μs
ImmutableList 10000 True 116.066 μs 175.379 μs 121.77 μs 171.507 μs 121.17 μs 169.641 μs 213.8 μs 171.575 μs 210.5 μs 168.528 μs
LinkedList 10000 True 116.991 μs 132.986 μs 126.44 μs 130.148 μs 126.81 μs 129.226 μs 155.2 μs 136.625 μs 155.6 μs 131.705 μs
ReadOnlyDictionary 10000 True 136.765 μs 332.409 μs 405.17 μs 304.997 μs 273.74 μs 319.528 μs 1,041.7 μs 579.102 μs 787.1 μs 607.477 μs
SortedSet 10000 True 137.815 μs 4,029.597 μs 265.47 μs 391.434 μs 270.67 μs 392.659 μs 4,392.3 μs 4,656.899 μs 4,368.5 μs 4,528.383 μs
Dictionary 10000 True 142.937 μs 334.870 μs 395.55 μs 306.255 μs 275.55 μs 312.003 μs 1,044.8 μs 588.393 μs 782.3 μs 639.324 μs
HashSet 10000 True 147.227 μs 283.599 μs 372.84 μs 273.213 μs 202.42 μs 275.069 μs 1,024.8 μs 549.739 μs 698.1 μs 568.376 μs
ImmutableSortedSet 10000 True 172.463 μs 4,155.903 μs 303.40 μs 494.140 μs 299.38 μs 486.520 μs 4,429.0 μs 4,526.199 μs 4,477.8 μs 4,659.316 μs
SortedList 10000 True 245.120 μs 4,363.556 μs 662.24 μs 684.466 μs 460.78 μs 681.867 μs 5,475.3 μs 4,975.379 μs 5,151.8 μs 5,177.425 μs
ImmutableList (Sorted) 10000 True 366.517 μs 4,170.982 μs 549.61 μs 888.906 μs 518.67 μs 897.213 μs 4,647.5 μs 4,585.707 μs 4,512.7 μs 4,591.297 μs
FrozenSet 10000 True 399.679 μs 1,549.158 μs 913.03 μs 698.686 μs 606.19 μs 729.071 μs 2,089.5 μs 1,398.326 μs 1,470.0 μs 1,409.665 μs
FrozenDictionary 10000 True 436.484 μs 1,441.103 μs 869.17 μs 819.518 μs 619.25 μs 839.095 μs 2,094.7 μs 1,458.341 μs 1,511.2 μs 1,516.703 μs
SortedDictionary 10000 True 743.652 μs 7,403.146 μs 1,104.86 μs 1,907.664 μs 997.43 μs 1,958.208 μs 7,726.8 μs 7,861.160 μs 7,489.4 μs 7,981.768 μs
ImmutableHashSet 10000 True 1,035.964 μs 2,709.511 μs 2,540.53 μs 2,616.598 μs 2,246.62 μs 2,628.180 μs 3,264.9 μs 2,983.712 μs 2,820.3 μs 2,972.986 μs
ImmutableSortedDictionary 10000 True 1,045.619 μs 13,859.086 μs 1,399.53 μs 3,041.821 μs 1,386.34 μs 3,011.636 μs 13,620.9 μs 14,449.871 μs 13,689.5 μs 14,415.510 μs
ImmutableDictionary 10000 True 1,381.476 μs 2,794.094 μs 2,666.65 μs 2,828.422 μs 2,392.36 μs 2,717.978 μs 4,178.5 μs 3,206.907 μs 3,143.3 μs 3,101.142 μs
MethodLengthSortedInt32StringStructIntsClassIntsRecordStructIntsRecordClassIntsStructStringsClassStringsRecordStructStringsRecordClassStrings
ReadOnlyCollection 1000000 False 504.324 μs 2,472.077 μs 3,355.06 μs 1,952.889 μs 3,348.69 μs 1,980.965 μs 9,988.4 μs 3,311.382 μs 9,307.7 μs 3,286.470 μs
Array 1000000 False 515.856 μs 1,746.981 μs 3,279.49 μs 1,685.417 μs 3,361.73 μs 1,699.744 μs 9,537.0 μs 3,268.163 μs 9,510.5 μs 3,307.651 μs
ImmutableArray 1000000 False 516.147 μs 1,772.569 μs 3,273.59 μs 1,698.699 μs 3,440.68 μs 1,701.287 μs 10,483.7 μs 3,272.491 μs 9,444.1 μs 3,282.731 μs
List 1000000 False 529.806 μs 2,453.267 μs 3,385.21 μs 1,914.800 μs 3,351.13 μs 1,925.687 μs 10,443.0 μs 3,284.328 μs 9,259.2 μs 3,298.947 μs
Dictionary 1000000 False 31,995.977 μs 61,127.048 μs 95,366.36 μs 60,327.741 μs 86,209.48 μs 60,767.570 μs 169,128.5 μs 111,899.153 μs 134,952.6 μs 111,311.340 μs
ReadOnlyDictionary 1000000 False 32,691.544 μs 61,574.407 μs 98,468.03 μs 62,046.867 μs 82,703.11 μs 60,075.867 μs 169,061.4 μs 110,552.000 μs 131,012.5 μs 111,836.913 μs
HashSet 1000000 False 33,712.833 μs 54,896.483 μs 92,534.76 μs 54,644.158 μs 55,756.19 μs 54,258.454 μs 166,453.3 μs 114,099.520 μs 125,852.4 μs 118,752.847 μs
List (Sorted) 1000000 False 51,104.713 μs 1,272,296.833 μs 69,169.95 μs 220,972.511 μs 68,037.01 μs 207,235.722 μs 1,510,138.4 μs 1,597,649.833 μs 1,551,474.3 μs 1,692,189.200 μs
Array (Sorted) 1000000 False 51,494.177 μs 1,261,504.233 μs 69,460.58 μs 197,477.022 μs 69,650.39 μs 194,178.900 μs 1,561,056.7 μs 1,563,808.800 μs 1,507,109.5 μs 1,723,026.467 μs
ImmutableArray (Sorted) 1000000 False 51,958.013 μs 1,254,252.433 μs 68,780.38 μs 194,048.133 μs 71,666.14 μs 208,567.000 μs 1,537,310.0 μs 1,567,698.933 μs 1,508,957.0 μs 1,700,343.400 μs
ImmutableList 1000000 False 70,960.167 μs 66,808.562 μs 81,617.96 μs 71,489.821 μs 83,067.50 μs 71,283.192 μs 86,172.9 μs 57,231.215 μs 82,798.1 μs 56,876.248 μs
LinkedList 1000000 False 82,392.728 μs 84,810.195 μs 94,274.66 μs 90,952.739 μs 96,208.36 μs 89,269.006 μs 83,882.4 μs 78,025.738 μs 82,806.8 μs 77,498.105 μs
SortedList 1000000 False 113,853.193 μs 1,480,264.133 μs 193,554.06 μs 301,168.667 μs 183,632.01 μs 306,761.850 μs 1,878,580.4 μs 1,886,570.833 μs 1,826,587.8 μs 2,043,428.367 μs
ImmutableSortedSet 1000000 False 123,215.547 μs 1,421,397.567 μs 152,350.92 μs 314,867.617 μs 152,072.15 μs 324,018.883 μs 1,749,357.3 μs 1,804,288.267 μs 1,706,557.2 μs 1,946,018.867 μs
FrozenDictionary 1000000 False 125,824.411 μs 618,932.333 μs 211,491.02 μs 161,481.422 μs 176,315.19 μs 175,977.083 μs 336,933.9 μs 262,421.450 μs 283,767.8 μs 265,990.750 μs
SortedSet 1000000 False 132,993.567 μs 1,412,164.933 μs 162,289.78 μs 315,448.083 μs 160,096.23 μs 315,208.317 μs 1,702,656.9 μs 1,777,829.900 μs 1,724,518.4 μs 1,930,465.767 μs
FrozenSet 1000000 False 139,661.489 μs 625,179.800 μs 200,634.72 μs 175,773.058 μs 161,055.81 μs 178,048.511 μs 352,984.7 μs 245,707.167 μs 274,479.2 μs 247,040.000 μs
ImmutableList (Sorted) 1000000 False 225,373.189 μs 1,440,594.067 μs 252,204.45 μs 378,184.633 μs 246,561.13 μs 373,668.200 μs 1,698,900.6 μs 1,667,373.167 μs 1,657,942.0 μs 1,809,876.100 μs
SortedDictionary 1000000 False 609,980.667 μs 2,126,734.967 μs 739,231.10 μs 1,067,929.233 μs 745,543.80 μs 1,093,100.200 μs 2,303,442.4 μs 2,417,957.433 μs 2,305,865.1 μs 2,546,313.000 μs
ImmutableHashSet 1000000 False 940,782.600 μs 1,050,838.967 μs 1,345,858.57 μs 1,155,167.933 μs 1,088,117.17 μs 1,062,482.900 μs 1,510,336.7 μs 1,115,422.667 μs 1,145,315.5 μs 1,160,763.567 μs
ImmutableSortedDictionary 1000000 False 968,602.200 μs 3,508,576.867 μs 1,457,313.17 μs 1,667,027.167 μs 1,434,820.20 μs 1,663,175.333 μs 4,135,377.6 μs 3,697,727.067 μs 4,077,824.1 μs 3,897,755.767 μs
ImmutableDictionary 1000000 False 985,886.700 μs 1,168,491.733 μs 1,354,303.10 μs 1,123,025.100 μs 1,061,682.70 μs 1,173,974.133 μs 1,605,377.8 μs 1,135,339.300 μs 1,227,295.7 μs 1,164,108.000 μs
MethodLengthSortedInt32StringStructIntsClassIntsRecordStructIntsRecordClassIntsStructStringsClassStringsRecordStructStringsRecordClassStrings
ReadOnlyCollection 1000000 True 507.657 μs 3,656.048 μs 3,293.87 μs 3,181.845 μs 3,390.67 μs 3,186.602 μs 16,916.9 μs 5,455.066 μs 16,802.8 μs 5,578.555 μs
Array 1000000 True 517.425 μs 2,969.073 μs 3,300.02 μs 3,035.039 μs 3,378.33 μs 3,026.706 μs 16,601.8 μs 5,476.214 μs 16,592.8 μs 5,642.840 μs
ImmutableArray 1000000 True 520.356 μs 2,974.764 μs 3,296.75 μs 3,018.099 μs 3,390.09 μs 3,015.545 μs 18,501.8 μs 5,477.453 μs 16,688.3 μs 5,580.492 μs
List 1000000 True 533.574 μs 3,629.443 μs 3,286.39 μs 3,199.480 μs 3,445.90 μs 3,164.733 μs 17,928.5 μs 5,461.394 μs 16,801.9 μs 5,572.833 μs
ImmutableArray (Sorted) 1000000 True 1,201.790 μs 145,644.625 μs 4,542.70 μs 28,134.218 μs 4,579.29 μs 28,134.045 μs 156,783.3 μs 164,471.025 μs 156,884.1 μs 173,624.989 μs
Array (Sorted) 1000000 True 5,856.667 μs 1,129,643.800 μs 21,387.96 μs 104,549.827 μs 17,908.28 μs 104,135.887 μs 1,222,815.8 μs 1,316,068.900 μs 1,239,819.4 μs 1,434,924.700 μs
List (Sorted) 1000000 True 5,877.452 μs 1,155,808.467 μs 18,011.67 μs 100,802.133 μs 21,601.00 μs 99,407.839 μs 1,213,193.5 μs 1,293,602.933 μs 1,227,750.5 μs 1,438,051.333 μs
Dictionary 1000000 True 32,210.608 μs 126,735.980 μs 96,648.89 μs 120,166.687 μs 82,675.68 μs 118,498.060 μs 281,732.3 μs 187,881.022 μs 281,131.2 μs 197,542.911 μs
ReadOnlyDictionary 1000000 True 33,912.242 μs 128,017.127 μs 93,465.42 μs 122,204.400 μs 82,684.19 μs 117,655.820 μs 278,656.2 μs 189,598.811 μs 269,814.9 μs 194,706.833 μs
HashSet 1000000 True 35,300.460 μs 132,884.167 μs 92,074.00 μs 137,878.008 μs 57,191.87 μs 143,134.783 μs 282,177.2 μs 189,317.022 μs 190,732.3 μs 202,440.711 μs
SortedList 1000000 True 51,409.652 μs 1,436,318.133 μs 117,013.70 μs 278,611.633 μs 118,840.49 μs 276,128.750 μs 1,676,060.0 μs 1,709,906.733 μs 1,655,944.9 μs 1,829,603.667 μs
ImmutableList 1000000 True 67,951.648 μs 81,748.695 μs 84,500.11 μs 81,404.257 μs 83,139.71 μs 84,200.256 μs 102,191.5 μs 63,083.425 μs 98,327.3 μs 62,545.704 μs
ImmutableSortedSet 1000000 True 75,711.886 μs 1,319,996.033 μs 105,094.11 μs 225,921.800 μs 107,157.75 μs 237,027.683 μs 1,489,399.2 μs 1,534,986.133 μs 1,453,673.0 μs 1,644,704.967 μs
LinkedList 1000000 True 84,287.589 μs 99,761.672 μs 94,579.08 μs 104,472.178 μs 94,499.33 μs 103,702.533 μs 105,297.4 μs 93,205.919 μs 104,024.1 μs 94,607.424 μs
SortedSet 1000000 True 90,717.528 μs 1,297,840.200 μs 109,118.06 μs 216,388.522 μs 112,447.05 μs 216,421.822 μs 1,508,580.2 μs 1,516,966.767 μs 1,414,749.6 μs 1,622,614.400 μs
FrozenDictionary 1000000 True 112,082.172 μs 1,281,507.900 μs 212,502.02 μs 259,589.817 μs 178,418.33 μs 266,822.083 μs 561,942.3 μs 442,312.200 μs 519,579.4 μs 470,388.933 μs
FrozenSet 1000000 True 129,252.750 μs 1,302,989.867 μs 206,294.76 μs 288,380.600 μs 163,747.90 μs 313,587.333 μs 566,892.6 μs 450,568.600 μs 435,732.6 μs 496,427.167 μs
ImmutableList (Sorted) 1000000 True 176,902.744 μs 1,413,845.300 μs 217,075.62 μs 371,582.167 μs 217,747.91 μs 388,608.967 μs 1,470,650.3 μs 1,518,881.367 μs 1,381,403.5 μs 1,643,588.667 μs
SortedDictionary 1000000 True 180,298.967 μs 1,383,237.633 μs 273,297.77 μs 564,813.300 μs 262,830.27 μs 541,675.867 μs 1,487,667.4 μs 1,491,527.233 μs 1,476,652.0 μs 1,503,189.433 μs
ImmutableHashSet 1000000 True 251,731.117 μs 1,201,671.967 μs 1,376,826.17 μs 1,248,229.333 μs 1,068,130.90 μs 1,238,479.167 μs 1,630,119.1 μs 1,305,933.000 μs 1,263,848.3 μs 1,313,633.200 μs
ImmutableDictionary 1000000 True 279,102.817 μs 1,283,939.367 μs 1,428,985.53 μs 1,267,845.800 μs 1,081,328.97 μs 1,276,222.100 μs 1,732,876.9 μs 1,315,924.700 μs 1,360,223.1 μs 1,316,530.100 μs
ImmutableSortedDictionary 1000000 True 288,083.850 μs 2,494,466.167 μs 455,724.87 μs 649,206.133 μs 465,749.07 μs 652,564.900 μs 2,430,546.8 μs 2,466,352.000 μs 2,537,376.7 μs 2,486,785.633 μs
Created by BenchmarkDotNetVisualizer