Closed ian-g-holm-intel closed 2 years ago
I ran a benchmark executing "cmd.exe /c echo this is a test" with CreateNoWindow set to true vs unset.
CreateNoWindow = true
CreateNoWindow unset
This proposed fix will check if the current application has a console or not. If it does not, it will set ProcessStartInfo.CreateNoWindow = true. If it does have a console, CreateNoWindow will not be set, avoiding the added overhead of setting it.
@Retik okay, just to make sure, you tested all previously scenarios with this and it works correctly, right? desktop/console/batch file, etc
I've observed a 30-40ms overhead added to the execution time of any process when you set ProcessStartInfo.CreateNoWindow to anything, true or false. I'm not sure why exactly this is, but you can see the difference in the benchmarks really easily. CliWrap sets CreateNoWindow = true and UseShellExecute = false. But as far as I can tell, UseShellExecute = false is the default and CreateNoWindow doesn't work unless UseShellExecute = true. So removing those two settings from the ProcessStartInfo is functionally equivalent to the way they are currently, but it allows processes to run without the 30ms overhead.