C# 是否有比StandardOutput.ReadToEnd更高效(时间复杂度)的方法?

C# 是否有比StandardOutput.ReadToEnd更高效(时间复杂度)的方法?,c#,performance,time-complexity,C#,Performance,Time Complexity,我想加快我的项目。我使用了Stopwatch类并计算了代码块之间的时间。大部分时间都花在字符串输出=p.StandardOutput.ReadToEnd()上行。是否有建议使用此代码来代替此代码 Process p = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = DBUpdater_Adresi; startInfo.RedirectStanda

我想加快我的项目。我使用了Stopwatch类并计算了代码块之间的时间。大部分时间都花在
字符串输出=p.StandardOutput.ReadToEnd()上行。是否有建议使用此代码来代替此代码

Process p = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = DBUpdater_Adresi;         
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
p.StartInfo = startInfo;
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();

大部分时间都花在这一行上的原因是,它等待您启动的程序的整个执行。它不需要时间,因为它效率低下,它需要时间,因为它在等待另一个进程

最后一行等待进程退出,但从输出流关闭到进程结束的时间很少