ToArray() is the fastest way to materialize IEnumerable on dotnet core:
BenchmarkDotNet=v0.10.8, OS=Mac OS X 10.12
Processor=Intel Core i7-4770HQ CPU 2.20GHz (Haswell), ProcessorCount=8
Frequency=1000000000 Hz, Resolution=1.0000 ns, Timer=UNKNOWN
dotnet cli version=1.0.4
[Host] : .NET Core 4.6.25211.01, 64bit RyuJIT
DefaultJob : .NET Core 4.6.25211.01, 64bit RyuJIT
Method | Mean | Error | StdDev | Median |
----------------- |------------:|----------:|----------:|------------:|
ToImmutableArray | 165.58 us | 4.994 us | 14.247 us | 161.43 us |
ToArray | 92.47 us | 1.823 us | 1.872 us | 91.84 us |
ToList | 156.74 us | 1.486 us | 1.317 us | 156.87 us |
ToImmutableList | 1,137.06 us | 16.654 us | 15.578 us | 1,136.40 us |
BenchmarkDotNet=v0.10.8, OS=Mac OS X 10.12
Processor=Intel Core i7-4770HQ CPU 2.20GHz (Haswell), ProcessorCount=8
Frequency=1000000000 Hz, Resolution=1.0000 ns, Timer=UNKNOWN
dotnet cli version=1.0.4
[Host] : .NET Core 4.6.25211.01, 64bit RyuJIT
DefaultJob : .NET Core 4.6.25211.01, 64bit RyuJIT
Method | Mean | Error | StdDev | Median |
----------------- |------------:|----------:|----------:|------------:|
ToImmutableArray | 165.58 us | 4.994 us | 14.247 us | 161.43 us |
ToArray | 92.47 us | 1.823 us | 1.872 us | 91.84 us |
ToList | 156.74 us | 1.486 us | 1.317 us | 156.87 us |
ToImmutableList | 1,137.06 us | 16.654 us | 15.578 us | 1,136.40 us |
BenchmarkDotNet=v0.10.8, OS=amzn 2017.03
Processor=Intel Xeon CPU E5-2686 v4 2.30GHz, ProcessorCount=2
Frequency=1000000000 Hz, Resolution=1.0000 ns, Timer=UNKNOWN
dotnet cli version=1.0.4
[Host] : .NET Core 4.6.25211.01, 64bit RyuJIT
DefaultJob : .NET Core 4.6.25211.01, 64bit RyuJIT
Method | Mean | Error | StdDev |
----------------- |------------:|----------:|----------:|
ToImmutableArray | 169.26 us | 0.7734 us | 0.6856 us |
ToArray | 99.04 us | 0.1849 us | 0.1544 us |
ToList | 171.49 us | 0.3799 us | 0.3554 us |
ToImmutableList | 1,234.29 us | 3.2099 us | 2.6805 us |