C # programs, how to effectively reduce CPU usage

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.