Recently developed projects, due to the use of CPU-intensive third-party program FFmpeg to process the video. So I looked up the internet and how to solve this problem.
As a result, you get a conclusion, reduce CPU utilization, you can reduce the number of CPU used, in the window system, open an EXE program, the system will use all the CPU as the default processing.
is not to reduce the number of CPU usage, you can reduce the CPU utilization, the answer is yes.
Reference code: Use Calc here as an example.
Process P = new process (); p.StartInfo.FileName = @ "C:\windows\system32\calc.exe"; P.startinfo.redirectstandardoutput = true; P.startinfo.redirectstandarderror = true;//redirect P.startinfo.useshellexecute = false; P.startinfo.createnowindow = true;//windowless p.start (); Set the number of CPU usage, where CPU0 and CPU1 p.processoraffinity = (IntPtr) (0x0001 | 0x0002) are used; P.close (); P.dispose ();
The number of modified CPUs is reduced, and the CPU occupancy rate is greatly reduced during the usage process.
Currently, there are many ways to reduce CPU usage, hear about hardware acceleration, and so on, but these features haven't been used yet.
C # programs, how to effectively reduce CPU usage