Linux programming-C ++ game program optimization

Source: Internet
Author: User
Linux programming-C ++ game program optimization-general Linux technology-Linux programming and kernel information. For details, see the following. In general, C ++ games are reusable and maintainable compared with C Programs. But is this really valuable? Can complicated C ++ be compared with traditional C Programs in terms of speed?

If you have a good compiler and a good understanding of the language, it is really possible to use C ++ to write some efficient game programs. This article describes several typical techniques you can use to accelerate your game. It assumes that you are already very certain about the benefits of using C ++, and you are quite familiar with the basic concepts of optimization.

The first basic concept that often benefits people is obviously the importance of profiling. If there is a lack of profiling, the programmer will make two kinds of errors. One is to optimize the wrong code: if the main indicator of a program is not efficiency, it is a waste of time to make it more efficient. Intuition is used to determine which code's main indicator is that efficiency is not credible and can only be measured directly. The second concept is that programmers often "optimize" to reduce the speed of code. This is a typical problem in C ++. A simple command line may generate a large number of machine code. You should always check the output of your compiler and analyze it.

1. Object Construction and Analysis

Object Construction and analysis is one of the core concepts of C ++ and a major part of the code generated by the compiler. Uncarefully designed programs often spend a lot of time calling constructors, copying objects and initializing temporary objects. Fortunately, the general feeling and a few simple rules can make the heavy object code run as little as C. It is not constructed unless necessary. The fastest code is the code that does not run at all. Why do you want to create an object that you don't even use? In the code below:
QUOTE:
Related Article

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.