C
C#14mo ago
Relevant

❔ Improving performance for Process.Start

I have an application that will run a python script using Process.Start. At the end, I'm reading the output with process.StandardOutput.ReadToEnd(). If I run the script on it's own, it runs in about 1 second. But running it this way takes about 2 seconds. Is there any way I could reduce some overhead? Is reading output time consuming?
9 Replies
Relevant
RelevantOP14mo ago
Maybe a pipe would be faster?
reflectronic
reflectronic14mo ago
maybe make the script write the output to a file? and then read the file
Relevant
RelevantOP14mo ago
I can give it a shot. I assumed that would be slower, but it wouldn't take long to test it out
cap5lut
cap5lut14mo ago
u could use IronPython and execute the python script directly in ur dotnet process for a quick start guide u can use this SO answer https://stackoverflow.com/questions/41064961/how-to-use-python-in-net-core-application#answer-61891763
reflectronic
reflectronic14mo ago
ipy can be much slower than even cpython for what it’s worth unless you want to do some complicated interop i would not do it if reading from stdout works then it is not complicated
SWR
SWR14mo ago
Without seeing your code, this is the best suggestion I can offer you https://stackoverflow.com/questions/4291912/process-start-how-to-get-the-output
Stack Overflow
Process.start: how to get the output?
I would like to run an external command line program from my Mono/.NET app. For example, I would like to run mencoder. Is it possible: To get the command line shell output, and write it on my tex...
SWR
SWR14mo ago
Using asynchronous data streams may be your fastest choice, but it can be annoying to set up.
jcotton42
jcotton4214mo ago
it's also lagging significantly behind cpython iirc
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server