DEV Community

Discussion on: C# REPL

Collapse
 
mosthated profile image
MostHated

I was interested in comparing the performance on Linux between PowerShell and dotnet-script, so I ran a script using both PSCore 7.x script using pwsh test1.ps1, the other was a C# csx using dotnet-script test1.csx.

I was expecting Powershell to take the win since the C# script had to compile, but the C# script blew it away in overall time taken from hitting enter until the terminal came back complete. It was just taking in a parameter, doing a simple loop over it a few times and printing the results.

The .ps1 script took between 5s30ms to 7s50ms
The .csx took between 0.23ms and 0.26ms.
I was quite impressed. I don't know if the csx has to run the dotnet runtime in the same way or in the same capacity as running a ps1 script? I expected the compilation to have to occur, then run the dotnet runtime, etc.

Either way, with those results, I might have to reconsider using PS for my scripts on linux and just go with C# instead.