Programming/MFC-C++

[코드 최적화] C와 C++의 속도와 성능 비교

빠릿베짱이 2012. 12. 6. 13:16
반응형

평가 지수:

- FREE: C와 C++은 별 차이 없음.

- CHEAP: C++이 C 보다 약간 더 비용이 듬.

- EXPENSIVE: C++이 C 보다 훨씬 더 많은 비용이 듬.

평가 항목:
1. encapsulation/classes
 2. namespaces
 3. inlining
 4. operator overloading
 5. constructors/destructors
 6. references
 7. inheritance and virtual functions
 8. templates
 9. STL(Standard Template Library)
 10. RTTI
 11. exceptions

평가 결과:

encapsulation/classes : the cost of function calls and use of pointers are FREE.

namespaces : Namespace has no cost associated with it: FREE.

inlining : Inlining in C++ is essential for good code generation and the cost is therefore FREE.

operator overloading : If used in a natural way, such as using + for imaginary numbers and concatenation operations, operator overloading is a powerful way of simplifying code writing and it is FREE.

constructors/destructors : Constructors and destructors are essentially FREE except for the actual code they contain.

references : References have the same cost as passing a pointer, and are FREE.

inheritance and virtual functions : Using virtual functions does come with a price. However, the code price paid is still CHEAP, and for many cases can be considered as almost FREE. In addition, virtual functions provides huge advantages for future code maintenance and product development.

templates : Templates can be FREE, CHEAP, or EXPENSIVE.

STL: Using STL reduces implementation time, compared with hand crafting, and the result is likely to work as intended but at a considerable code and data cost. Using the STL library is EXPENSIVE.

RTTI: It requires the literal names of all classes to be part of the application binary, and also adds extra code, it is EXPENSIVE.

exceptions:
A lot of extra code is needed to implement the exception mechanism, it is EXPENSIVE.

반응형

'Programming > MFC-C++' 카테고리의 다른 글

JSON C++  (0) 2012.12.17
[코드 네이밍] Coding Naming Rules  (0) 2012.12.06
SURF 중요 코드  (0) 2012.11.12
SURF(Speed up Robust Features) Code  (0) 2012.11.12
AR 구현 관련 자료  (0) 2012.11.06