C
C#9mo 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
Relevant9mo ago
Maybe a pipe would be faster?
reflectronic
reflectronic9mo ago
maybe make the script write the output to a file? and then read the file
Relevant
Relevant9mo ago
I can give it a shot. I assumed that would be slower, but it wouldn't take long to test it out
cap5lut
cap5lut9mo 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
reflectronic9mo 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
SWR9mo 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
SWR9mo ago
Using asynchronous data streams may be your fastest choice, but it can be annoying to set up.
jcotton42
jcotton429mo ago
it's also lagging significantly behind cpython iirc
Accord
Accord8mo 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
More Posts