Developer Martin Finkel conducted a performance comparison between C and C# by porting a specific video filter—the Gaussian blur—from the VLC media player. The experiment aimed to determine if C#'s managed nature and garbage collector would significantly hinder performance compared to C, which is the native language of VLC. To ensure a fair comparison, Finkel created a line-by-line C# port that used the same loops, integer math, and raw pointers as the original C implementation. The C# version was compiled using .NET Native AOT, allowing it to run as a native DLL plugin within VLC.

Developer Martin Finkel conducted a performance comparison between C and C# by porting a specific video filter—the Gaussian blur—from the VLC media player.
The initial results showed a clear performance gap: the C# port took approximately 23% longer per frame than the original C code. Analysis of the machine code revealed that the .NET RyuJIT compiler emitted more instructions than the Clang compiler, specifically by recomputing loop bounds and keeping sums in memory rather than registers. However, by making two small adjustments—hoisting loop bounds into local variables and using `nint` for indices to avoid 32-to-64-bit conversions—the C# port's performance improved to within 8% of the C version. This demonstrated that much of the performance delta was attributable to how the compiler handled specific C# constructs rather than inherent language limitations.

The initial results showed a clear performance gap where the C# port took approximately 23% longer per frame than the original C code.
In subsequent rounds of optimization, both versions were improved using algorithmic refinements such as replacing division with multiplication, optimizing memory access patterns, and utilizing the symmetry of the Gaussian bell curve. In the final 'tuned' round, both versions utilized AVX2 SIMD instructions to achieve massive speedups, with the C# version performing nearly on par with C. Finkel concluded that while C remains the superior choice for the final 10% of performance, C# is a highly viable and productive choice for CPU-bound VLC plugins, provided developers account for the specific ways the .NET compiler optimizes their code. The experiment was conducted on a 1080p clip using an 11th-gen Intel Core i7 processor.

In subsequent rounds of optimization, both versions were improved using algorithmic refinements such as replacing division with multiplication.

In the final 'tuned' round, both versions utilized AVX2 SIMD instructions to achieve massive speedups, with the C# version performing nearly on par with C.