Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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


Ïà¹ØÎĵµ£º

תÔØ:Hadoop Ó¦¸ÃÓÃC++ʵÏÖ£¬¶ø²»ÊÇJava

http://www.trendcaller.com/2009/05/hadoop-should-target-cllvm-not-java.html
Sunday, May 10, 2009
Hadoop should target C++/LLVM, not Java (because of watts)
< type="text/javascript">
digg_url="http://www.trendcaller.com/2009/05/hadoop-should-target-cllvm-not-java.html";
Over the years, ......

C ÓïÑÔ¶þάÊý×éºÍË«ÖØÖ¸Õë

#include "Stdio.h"
#include "Conio.h"
#include
#define size 81
#define lim 5
#define tstr "ABCDEFGH"
void display(char **p,int i);
void display2(char *p[],int i);
void display3(char (*p)[40],int i);
void testint();
int main(void)
{
testint();
getch();
return 0;
}
test1() ......

C/C++Öеĺê


ºê¶¨ÒåÁËÒ»¸ö´ú±íÌض¨ÄÚÈݵıêʶ·û¡£Ô¤´¦Àí¹ý³Ì»á°ÑÔ´´úÂëÖгöÏֵĺê±êʶ·ûÌæ»»³Éºê¶¨ÒåʱµÄÖµ¡£ºê
×î³£¼ûµÄÓ÷¨ÊǶ¨Òå´ú±íij¸öÖµµÄÈ«¾Ö·ûºÅ¡£ºêµÄµÚ¶þÖÖÓ÷¨ÊǶ¨Òå´ø²ÎÊýµÄºê£¬ÕâÑùµÄºê¿ÉÒÔÏóº¯ÊýÒ»Ñù
±»µ÷Ó㬵«ËüÊÇÔÚµ÷ÓÃÓï¾ä´¦Õ¹¿ªºê£¬²¢Óõ÷ÓÃʱµÄʵ¼Ê²ÎÊýÀ´´úÌ涨ÒåÖеÄÐÎʽ²ÎÊý¡£
1.#defineÖ¸Áî
#defineÔ¤´¦Àí ......

C/C++Îļþ²Ù×÷

ÔÚC++ÖУ¬¿ÉÒÔʹÓöàÖÖ·½·¨¶ÔÎļþ½øÐвÙ×÷£¬Èç»ùÓÚCµÄÎļþ²Ù×÷¡¢»ùÓÚC++µÄÎļþ²Ù×÷µÈµÈ£»
¡ô»ùÓÚCµÄÎļþ²Ù×÷
ÔÚANSI CÖУ¬¶ÔÎļþµÄ²Ù×÷·ÖΪÁ½ÖÖ·½Ê½£¬¼´Á÷ʽÎļþ²Ù×÷ºÍI/OÎļþ²Ù×÷£¬ÏÂÃæ¾Í·Ö±ð½éÉÜÖ®¡£
Ò».Á÷ʽÎļþ²Ù×÷
ÕâÖÖ·½Ê½µÄÎļþ²Ù×÷ÓÐÒ»¸öÖØÒªµÄ½á¹¹FILE£¬FILEÔÚstdio.hÖж¨ÒåÈçÏ£º
 typedef struct {
i ......

Ò»¸öLinuxÏÂCÏ̳߳صÄʵÏÖ

ʲôʱºòÐèÒª´´½¨Ï̳߳ØÄØ£¿¼òµ¥µÄ˵£¬Èç¹ûÒ»¸öÓ¦ÓÃÐèҪƵ·±µÄ´´½¨ºÍÏú»ÙỊ̈߳¬¶øÈÎÎñÖ´ÐеÄʱ¼äÓַdz£¶Ì£¬ÕâÑùÏ̴߳´½¨ºÍÏú»ÙµÄ´øÀ´µÄ¿ªÏú¾Í²»ÈݺöÊÓ£¬ÕâʱҲÊÇÏ̳߳ظóö³¡µÄ»ú»áÁË¡£Èç¹ûÏ̴߳´½¨ºÍÏú»Ùʱ¼äÏà±ÈÈÎÎñÖ´ÐÐʱ¼ä¿ÉÒÔºöÂÔ²»¼Æ£¬ÔòûÓбØҪʹÓÃÏ̳߳ØÁË¡£
ÏÂÃæÊÇLinuxϵͳÏÂÓÃCÓïÑÔ´´½¨µÄÒ»¸öÏ̳߳ء£Ï̳߳ػ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ