c# - Process.Start() significantly slower than executing in console -
i have performance problems executing .exe using process.start()
. execution takes 5 times longer .net console. can cause this? here test program:
public static void main(string[] argv) { (int = 0; < 10; i++) { processstartinfo psi = new processstartinfo(exepath, args); process ps = new process {startinfo = psi}; stopwatch sw = stopwatch.startnew(); ps.start(); ps.waitforexit(); sw.stop(); console.writeline(i+" elapsed time: " + sw.elapsedmilliseconds + "ms."); thread.sleep(1000); } }
the result this:
0 elapsed time 4310ms. 1 elapsed time 4330ms. 2 elapsed time 4280ms. ...
running in cmd window returns (sub 1 second execution). tried timing in console using
> powershell measure-command { cmd /c start /wait %exe% %args% }
which shows around 750ms execution, 5-6 times faster. not sure did right, 750ms feels execution time.
at first reading std out , thought related this, see e.g. process takes longer finish in cmd , similar questions. in simple test program i'm not reading output now, executing.
possible causes have alreay ruled out cause no difference in exec time:
- debugger/no debugger
- debug/release build of .net host process
- working directory
- platform of host .net process any/x86/x64 (exe native x64)
- useshellexecute true/false
what know executable (it's rust statement completion tool 'racer' https://github.com/phildawes/racer) go off , open lots of files. matter when coming .net host, e.g. wrt. security, causes slowdown? else cause huge performance difference?
the difference in running time in case due different versions of executed (racer.exe
) file, , had nothing fact 1 being executed .net process , other command line.
there shouldn't difference when running executable .net using system calls execute program.
Comments
Post a Comment