Tham khảo tài liệu 'ansi/iso c++ professional programmer's handbook phần 10', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | ANSI ISO C Professional Programmer s Handbook - Chapter 12 - Optimizing Your Code asm mov a ecx Interacting with the Operating System Directly API functions and classes enable you to interact with the operating system. Sometimes however executing a system command directly can be much faster. For this purpose you can use the standard function system that takes a shell command as a const char . For example on a DOS Windows system you can display the files in the current directory as follows include cstdlib using namespace std int main system dir execute the dir command Here again the tradeoff is between speed on the one hand and portability and future extensibility on the other hand. Conclusions In an ideal world software designers and developers might focus their efforts on robust extensible and readable code. Fortunately the current state of affairs in the software world is much closer to that ideal than it was 15 30 or 50 years ago. Notwithstanding that performance tuning and optimizations will probably remain a necessity for a long time. The faster hardware becomes the more the software that runs on it is required to meet higher demands. Speech recognition online translation of natural languages neural networks and complex mathematical computations are only a few examples of resource-hungry applications that will evolve in the future and require careful optimizations. Textbooks often recommend that you put off optimization consideration to the final stages of testing. Indeed the primary goal is to get the system to work correctly. Nonetheless some of the techniques presented here -- such as declaring objects locally preferring prefix to postfix operators and using initialization instead of assignment -- need to become a natural habit. It is a well-known fact that programs usually spend 90 of their time executing only 10 of their code the numbers might vary but they range between 80 and 20 to 95 and 5 . The first step in optimization is therefore identifying that