Optimizing Your C/C++ Applications
C/C++ optimizing compilers are great--but there *are* a few techniques for hand-tuning your code to run as efficiently as possible on the AMD Athlon64 and Opteron processors, especially when developing DLLs, device drivers, or other performance-bound pieces of code.
Alan Zeichick
Share |
6/21/2004
Sidebar: Know the Code
A code profiler can help determine which parts of your application should be optimized. You should always use a profiler both before and after optimization to see if your change actually made an improvement—with C/C++, you can never be sure if your hand-tuning methods are better than those of your optimizing compiler!
The smart engineers at AMD have spent a lot of time identifying places where C/C++ developers can optimize code for best performance. Some of these optimizations might look familiar—they're generally great coding practice for any 32-bit or 64-bit platform or operating system. In fact, most of these suggestions are appropriate whether you're developing 32-bit or 64-bit apps. Others are specifically for 64-bit applications running on the AMD64 architecture. This article will look at six optimizations; Part 2 will examine eight more.
#1. Declare as static functions that are not used outside the file where they are defined
Declaring a function as static forces an internal linkage within that file, which can improve the performance of the code. Functions that are not declared as static default to external linkage, which may inhibit certain optimizations, such as aggressive inlining, with some C/C++ compilers.
#2: Use array notation instead of pointer notation when working with arrays
You can use either array operators ([]) or pointers to access the elements of an array. However, it's hard for the compiler to optimize pointers because the pointers are, by default, less constrained—the compiler has to assume that the pointer can read/write to any location in memory. Because array nota
相关文档:
最近经常和公司做JAVA的兄弟们打交道,由于需要统加密算法,所以要求做一个加密的DLL文件供兄弟们调用,根据网上各位大虾们的经验,在加上个人在摸索过程中的体会,现在将流程以及个人心得贴上,以供以后漫漫程序生涯参考,如有不对的还请各位大力指正。
第一步是编写java类, ......
宏定义了一个代表特定内容的标识符。预处理过程会把源代码中出现的宏标识符替换成宏定义时的值。宏
最常见的用法是定义代表某个值的全局符号。宏的第二种用法是定义带参数的宏,这样的宏可以象函数一样
被调用,但它是在调用语句处展开宏,并用调用时的实际参数来代替定义中的形式参数。
1.#define指令
#define预处理 ......
2.1 可测性问题详解(2)
接下来我们讨论重点问题:覆盖输入。一个函数,输入会有哪些呢?输入包括两方面:外部输入,内部输入。外部输入容易理解,就是函数外部可以设定的输入,包括参数,全局变量,成员变量。
&nb ......
--------如果你用的是或打算用Eclipse For C++,那么从这里看,
1. 首先下载Eclipse for C++, 最新版是基于Eclipse 3.5.2的,eclipse-cpp-galileo-SR2-win32.zip
2. 解压,直接运行。注意,至少JDK你已经安装了(我用的是JDK1.6)。运行后welcome页面出现,进入Tutorials。先读Tutorial是个好习惯。
3. 首先 什么是CDT... ......