Skip to content

LocalList (collection on stack)

Kirill edited this page Feb 20, 2020 · 3 revisions

Create and use

var buffer = new LocalList<Boo>();
buffer.Add(boo1);
buffer.Add(boo2);
...

foreach (var boo in buffer) {
   Console.WriteLine(boo.Id);
}

buffer.Where(boo => boo.Id > 5);

Benchmarks

Method Count Mean Error StdDev Ratio Gen 0 Gen 1 Allocated
List_Add 4 3.441 ns 0.0354 ns 0.0331 ns 1.00 0.0014 - 9 B
LocalVector_Add 4 2.638 ns 0.0327 ns 0.0306 ns 0.77 - - -
Span_Add 4 2.073 ns 0.0179 ns 0.0158 ns 0.60 0.0009 - 6 B
List_Iteration 4 7.571 ns 0.1358 ns 0.1270 ns 1.00 0.0014 - 9 B
LocalVector_Iteration 4 5.916 ns 0.0508 ns 0.0450 ns 0.78 - - -
Span_Iteration 4 8.091 ns 0.0854 ns 0.0799 ns 1.07 0.0009 - 6 B
List_GroupBy 4 38.972 ns 0.3626 ns 0.3392 ns 1.00 0.0108 - 68 B
LocalVector_GroupBy 4 50.495 ns 0.4076 ns 0.3812 ns 1.30 - - -
List_Join 4 58.397 ns 0.3899 ns 0.3647 ns 1.00 0.0144 - 90 B
LocalVector_Join 4 33.049 ns 0.2622 ns 0.2324 ns 0.57 - - -
List_ManyLinq 4 126.200 ns 1.0256 ns 0.8564 ns 1.00 0.0345 - 218 B
LocalVector_ManyLinq 4 125.057 ns 0.4907 ns 0.4350 ns 0.99 - - -
List_Remove 4 15.161 ns 0.1612 ns 0.1508 ns 1.00 0.0014 - 9 B
LocalVector_Remove 4 11.383 ns 0.0603 ns 0.0564 ns 0.75 - - -
List_Select 4 15.843 ns 0.0604 ns 0.0536 ns 1.00 0.0025 - 16 B
LocalVector_Select 4 10.475 ns 0.2011 ns 0.2235 ns 0.66 - - -
List_ToArray 4 8.124 ns 0.0916 ns 0.0812 ns 1.00 0.0023 - 14 B
LocalVector_ToArray 4 5.604 ns 0.0536 ns 0.0448 ns 0.69 0.0009 - 6 B
Span_ToArray 4 1.922 ns 0.0514 ns 0.0429 ns 0.24 0.0009 - 6 B
List_Where 4 14.750 ns 0.1341 ns 0.1254 ns 1.00 0.0025 - 16 B
List_FindAll 4 11.030 ns 0.0779 ns 0.0729 ns 0.75 0.0028 - 18 B
LocalVector_Where 4 10.277 ns 0.0990 ns 0.0877 ns 0.70 - - -
List_Where_ToArray 4 21.149 ns 0.4222 ns 0.7504 ns 1.00 0.0041 - 26 B
LocalVector_Where_ToArray 4 13.078 ns 0.1922 ns 0.1798 ns 0.63 0.0006 - 4 B
List_Add 10 12.926 ns 0.1850 ns 0.1731 ns 1.00 0.0052 - 33 B
LocalVector_Add 10 5.502 ns 0.0313 ns 0.0244 ns 0.42 - - -
Span_Add 10 3.852 ns 0.0196 ns 0.0153 ns 0.30 0.0017 - 10 B
List_Iteration 10 9.937 ns 0.2311 ns 0.2923 ns 1.00 0.0022 - 14 B
LocalVector_Iteration 10 9.701 ns 0.0504 ns 0.0472 ns 0.97 - - -
Span_Iteration 10 8.521 ns 0.0899 ns 0.0797 ns 0.85 0.0017 - 10 B
List_GroupBy 10 71.959 ns 0.5214 ns 0.4877 ns 1.00 0.0161 - 102 B
LocalVector_GroupBy 10 83.630 ns 0.2430 ns 0.2273 ns 1.16 - - -
List_Join 10 111.531 ns 0.3870 ns 0.3232 ns 1.00 0.0265 - 167 B
LocalVector_Join 10 117.925 ns 0.3964 ns 0.3708 ns 1.06 - - -
List_ManyLinq 10 238.136 ns 1.0246 ns 0.9584 ns 1.00 0.0584 0.0004 366 B
LocalVector_ManyLinq 10 425.516 ns 1.3847 ns 1.2952 ns 1.79 - - -
List_Remove 10 31.604 ns 0.2091 ns 0.1956 ns 1.00 0.0021 - 14 B
LocalVector_Remove 10 52.423 ns 0.3658 ns 0.3422 ns 1.66 - - -
List_Select 10 22.865 ns 0.0749 ns 0.0664 ns 1.00 0.0033 - 21 B
LocalVector_Select 10 17.396 ns 0.0883 ns 0.0737 ns 0.76 - - -
List_ToArray 10 8.174 ns 0.0553 ns 0.0461 ns 1.00 0.0038 - 24 B
LocalVector_ToArray 10 11.211 ns 0.0623 ns 0.0583 ns 1.37 0.0017 - 10 B
Span_ToArray 10 2.284 ns 0.0195 ns 0.0182 ns 0.28 0.0017 - 10 B
List_Where 10 22.720 ns 0.0935 ns 0.0874 ns 1.00 0.0033 - 21 B
List_FindAll 10 20.528 ns 0.1968 ns 0.1744 ns 0.90 0.0050 - 31 B
LocalVector_Where 10 18.991 ns 0.0860 ns 0.0805 ns 0.84 - - -
List_Where_ToArray 10 23.612 ns 0.1297 ns 0.1213 ns 1.00 0.0056 - 35 B
LocalVector_Where_ToArray 10 24.195 ns 0.1408 ns 0.1317 ns 1.02 0.0014 - 9 B
List_Add 15 13.709 ns 0.1196 ns 0.1119 ns 1.00 0.0052 - 33 B
LocalVector_Add 15 11.522 ns 0.0865 ns 0.0767 ns 0.84 0.0023 - 14 B
Span_Add 15 5.003 ns 0.0331 ns 0.0309 ns 0.36 0.0023 - 14 B
List_Iteration 15 13.132 ns 0.3489 ns 0.3093 ns 1.00 0.0028 - 18 B
LocalVector_Iteration 15 14.372 ns 0.0674 ns 0.0598 ns 1.09 0.0010 - 6 B
Span_Iteration 15 8.857 ns 0.1515 ns 0.1343 ns 0.67 0.0023 - 14 B
List_GroupBy 15 86.259 ns 0.4682 ns 0.4380 ns 1.00 0.0168 - 106 B
LocalVector_GroupBy 15 111.916 ns 0.8427 ns 0.7882 ns 1.30 0.0027 - 17 B
List_Join 15 148.744 ns 0.8599 ns 0.8043 ns 1.00 0.0349 - 219 B
LocalVector_Join 15 231.299 ns 1.5131 ns 1.4154 ns 1.56 0.0019 - 13 B
List_ManyLinq 15 326.887 ns 1.4260 ns 1.3339 ns 1.00 0.0759 0.0008 477 B
LocalVector_ManyLinq 15 814.412 ns 3.0927 ns 2.8929 ns 2.49 0.0076 - 54 B
List_Remove 15 45.089 ns 0.5050 ns 0.4477 ns 1.00 0.0028 - 18 B
LocalVector_Remove 15 103.205 ns 0.9664 ns 0.9039 ns 2.29 0.0010 - 6 B
List_Select 15 28.500 ns 0.4309 ns 0.3820 ns 1.00 0.0039 - 25 B
LocalVector_Select 15 24.813 ns 0.1065 ns 0.0996 ns 0.87 0.0010 - 6 B
List_ToArray 15 8.664 ns 0.0555 ns 0.0519 ns 1.00 0.0051 - 32 B
LocalVector_ToArray 15 15.803 ns 0.0898 ns 0.0840 ns 1.82 0.0033 - 21 B
Span_ToArray 15 2.527 ns 0.0138 ns 0.0129 ns 0.29 0.0023 - 14 B
List_Where 15 28.194 ns 0.1655 ns 0.1468 ns 1.00 0.0039 - 25 B
List_FindAll 15 27.428 ns 0.1162 ns 0.1087 ns 0.97 0.0080 - 50 B
LocalVector_Where 15 27.389 ns 0.0990 ns 0.0926 ns 0.97 0.0010 - 6 B
List_Where_ToArray 15 33.249 ns 0.2275 ns 0.2128 ns 1.00 0.0097 - 61 B
LocalVector_Where_ToArray 15 36.947 ns 0.2595 ns 0.2300 ns 1.11 0.0041 - 26 B
List_Add 25 21.078 ns 0.0719 ns 0.0637 ns 1.00 0.0097 - 61 B
LocalVector_Add 25 21.144 ns 0.1350 ns 0.1263 ns 1.00 0.0047 - 30 B
Span_Add 25 8.589 ns 0.1726 ns 0.2244 ns 0.41 0.0036 - 22 B
List_Iteration 25 16.807 ns 0.2576 ns 0.2151 ns 1.00 0.0041 - 26 B
LocalVector_Iteration 25 21.567 ns 0.3299 ns 0.3086 ns 1.28 0.0023 - 14 B
Span_Iteration 25 11.611 ns 0.2293 ns 0.2145 ns 0.69 0.0036 - 22 B
List_GroupBy 25 137.070 ns 2.6324 ns 3.1337 ns 1.00 0.0229 - 144 B
LocalVector_GroupBy 25 183.210 ns 3.5955 ns 4.4156 ns 1.34 0.0082 - 52 B
List_Join 25 239.267 ns 2.1203 ns 1.9833 ns 1.00 0.0557 0.0004 350 B
LocalVector_Join 25 542.522 ns 7.6519 ns 6.3897 ns 2.27 0.0046 - 29 B
List_ManyLinq 25 521.390 ns 2.7673 ns 2.4532 ns 1.00 0.1167 0.0015 734 B
LocalVector_ManyLinq 25 1,986.088 ns 20.1014 ns 18.8029 ns 3.81 0.0183 - 122 B
List_Remove 25 79.091 ns 1.5147 ns 1.4168 ns 1.00 0.0040 - 26 B
LocalVector_Remove 25 248.374 ns 1.7898 ns 1.6742 ns 3.14 0.0023 - 14 B
List_Select 25 39.141 ns 0.7578 ns 0.9022 ns 1.00 0.0052 - 33 B
LocalVector_Select 25 37.954 ns 0.2017 ns 0.1887 ns 0.97 0.0023 - 14 B
List_ToArray 25 9.472 ns 0.0838 ns 0.0784 ns 1.00 0.0076 0.0000 48 B
LocalVector_ToArray 25 25.182 ns 0.1474 ns 0.1379 ns 2.66 0.0059 - 37 B
Span_ToArray 25 2.879 ns 0.0285 ns 0.0267 ns 0.30 0.0036 - 22 B
List_Where 25 38.883 ns 0.2699 ns 0.2393 ns 1.00 0.0052 - 33 B
List_FindAll 25 41.154 ns 0.3769 ns 0.3526 ns 1.06 0.0137 - 86 B
LocalVector_Where 25 41.617 ns 0.2291 ns 0.2143 ns 1.07 0.0023 - 14 B
List_Where_ToArray 25 48.577 ns 0.2971 ns 0.2779 ns 1.00 0.0146 - 92 B
LocalVector_Where_ToArray 25 61.181 ns 0.3528 ns 0.3300 ns 1.26 0.0078 - 50 B
Clone this wiki locally