Benchpress

What Is The Fastest Way To Filter

(@ 2095 Mhz)

Filtering a Pipeline

Technique RepeatCount Time RelativeSpeed Throughput
DotScriptBlockVariable 100 00:00:00.009875 1x 10126.48/s
ScriptBlockVariable 100 00:00:00.011455 1.16x 8729.51/s
Filter 100 00:00:00.011673 1.18x 8566.41/s
WhereObject 100 00:00:00.033700 3.41x 2967.36/s
InlineScriptBlock 100 00:00:00.039923 4.04x 2504.78/s
DotInline 100 00:00:00.040216 4.07x 2486.57/s

Filtering by Property Values

Technique RepeatCount Time RelativeSpeed Throughput
ForEach Loop 10 00:00:00.375881 1x 26.6/s
Pipe to ScriptBlock 10 00:00:00.988488 2.63x 10.12/s
.Where Method 10 00:00:05.675457 15.1x 1.76/s
Where-Object Property (Positional) 10 00:00:12.006219 31.94x 0.83/s

Filtering Values

Technique RepeatCount Time RelativeSpeed Throughput
Operator Filter (Assumed Array) 10 00:00:00.010150 1x 985.21/s
ForEach Loop 10 00:00:00.015252 1.5x 655.64/s
Operator Filter (Explicit Array) 10 00:00:00.038972 3.84x 256.59/s
Pipe to ScriptBlock 10 00:00:00.126446 12.46x 79.09/s
.Where Method 10 00:00:00.625700 61.64x 15.98/s
Linq.Enumerable::Where 10 00:00:00.833802 82.15x 11.99/s
Where-Object Script (Positional) 10 00:00:01.782858 175.65x 5.61/s