C++´úÂëÒ»Ö±ÒÔÆäÔËÐÐʱµÄ¸ßÐÔÄܸߵ÷Ãæ¶ÔÊÀÈË£¬ µ«ÊÇ˵Æð±àÒëËٶȣ¬È´Ö»Óе͵÷µÄ·ÝÁË¡£±ÈÈçÎÒÏÖÔÚ¹¤×÷µÄÔ´´úÂ룬ÄÄÅÂʹÓÃIncredibuildµ÷¶¯½ü°Ų̀»ú×Ó£¬Ò»¸öÍêÕûµÄbuildÒ²ÐèÒªËĸöСʱ£¬¿Ö²À£¡£¡£¡ËäȻƽʱ¿ª·¢Ò»°ã²»ÐèÒªÔÚ±¾µØ×öÍêÕûµÄbuild£¬µ«±àÒ뼸¸öÏà¹ØµÄ¹¤³Ì¾Í¹»ÄãµÈÉϺÃÒ»¶Îʱ¼äµÄÁË£¨ÀÏÍâ¹ÜÕâ¸ö½Ðmonkey around£¬Ï൱ÐÎÏ󣩡£ÏëÏëÈô¸ÉÄêÔÚһ̨µ¥ºË2.8GHZÉϹ¤×÷ʱµÄ³¡¾° - ÃæÇ°·Å±¾Ê飬һµãbuild°´Å¥£¬¾ÍµÍÍ·¶ÁÒ»»áÊé~~~Íùʲ»¿°»ØÊס£
¿ÉÒÔÏëÏó£¬Èç¹û²»¼ÓÒÔÖØÊÓ£¬±àÒëËٶȼ«ÓпÉÄÜ»á³ÉΪ¿ª·¢¹ý³ÌÖеÄÒ»¸öÆ¿¾±¡£ÄÇô£¬ÎªÊ²Ã´C++Ëü¾Í±àÒëµÄÕâôÂýÄØ£¿
ÎÒÏë×îÖØÒªµÄÒ»¸öÔÒòÓ¦¸ÃÊÇC++»ù±¾µÄ"Í·Îļþ-Ô´Îļþ"µÄ±àÒëÄ£ÐÍ£º
ÿ¸öÔ´Îļþ×÷Ϊһ¸ö±àÒëµ¥Ôª£¬¿ÉÄÜ»á°üº¬ÉÏ°ÙÉõÖÁÉÏǧ¸öÍ·Îļþ£¬¶øÔÚÿһ¸ö±àÒëµ¥Ôª£¬ÕâЩͷÎļþ¶¼»á±»´ÓÓ²Å̶Á½øÀ´Ò»±é£¬È»ºó±»½âÎöÒ»±é¡£
ÿ¸ö±àÒëµ¥Ôª¶¼»á²úÉúÒ»¸öobjÎļþ£¬È»ºóËùÒÔÕâЩobjÎļþ»á±»linkµ½Ò»Æ𣬲¢ÇÒÕâ¸ö¹ý³ÌºÜÄѲ¢ÐС£
ÕâÀÎÊÌâÔÚÓÚÎÞÊýÍ·ÎļþµÄÖظ´loadÓë½âÎö£¬ÒÔ¼°Ãܼ¯µÄ´ÅÅ̲Ù×÷¡£
ÏÂÃæ´Ó¸÷¸ö½Ç¶È¸ø³öһЩ¼Ó¿ì±àÒëËٶȵÄ×ö·¨£¬Ö÷Òª»¹ÊÇÕë¶ÔÉÏÃæÌá³öµÄÕâ¸ö¹Ø¼üÎÊÌâ¡£
Ò»¡¢´úÂë½Ç¶È
ÔÚÍ·ÎļþÖÐʹÓÃÇ°ÖÃÉùÃ÷£¬¶ø²»ÊÇÖ±½Ó°üº¬Í·Îļþ¡£
²»ÒªÒÔΪÄãÖ»ÊǶà¼ÓÁËÒ»¸öÍ·Îļþ£¬ÓÉÓÚÍ·ÎļþµÄ"±»°üº¬"ÌØÐÔ£¬ÕâÖÖЧ¹û¿ÉÄܻᱻÎÞÏÞ·Å´ó¡£ËùÒÔ£¬Òª¾¡Ò»ÇпÉÄÜʹͷÎļþ¾«¼ò¡£ºÜ¶àʱºòÇ°ÖÃÉêÃ÷ij¸önamespaceÖеÄÀà»á±È½ÏÍ´¿à£¬¶øÖ±½Óinclude»á·½±ãºÜ¶à£¬Ç§ÍòÒªµÖÖÆסÕâÖÖÓÕ»ó£»ÀàµÄ³ÉÔ±£¬º¯Êý²ÎÊýµÈÒ²¾¡Á¿ÓÃÒýÓã¬Ö¸Õ룬ΪǰÖÃÉùÃ÷´´ÔìÌõ¼þ¡£
ʹÓÃPimplģʽ
PimplÈ«³ÆΪPrivate Implementation¡£´«Í³µÄC++µÄÀàµÄ½Ó¿ÚÓëʵÏÖÊÇ»ìÏýÔÚÒ»ÆðµÄ£¬¶øPimplÕâÖÖ×ö·¨Ê¹µÃÀàµÄ½Ó¿ÚÓëʵÏÖµÃÒÔÍêÈ«·ÖÀë¡£Èç´Ë£¬Ö»ÒªÀàµÄ¹«¹²½Ó¿Ú±£³Ö²»±ä£¬¶ÔÀàʵÏÖµÄÐÞ¸ÄʼÖÕÖ»Ðè±àÒë¸Ãcpp£»Í¬Ê±£¬¸ÃÀàÌṩ¸øÍâ½çµÄÍ·ÎļþÒ²»á¾«¼òÐí¶à¡£
¸ß¶ÈÄ£¿é»¯
Ä£¿é»¯¾ÍÊǵÍñîºÏ£¬¾ÍÊǾ¡¿ÉÄܵļõÉÙÏ໥ÒÀÀµ¡£ÕâÀïÆäʵÓÐÁ½¸ö²ãÃæµÄÒâ˼¡£Ò»ÊÇÎļþÓëÎļþÖ®¼ä£¬Ò»¸öÍ·ÎļþµÄ±ä»¯£¬¾¡Á¿²»ÒªÒýÆðÆäËûÎļþµÄÖØбàÒ룻¶þÊǹ¤³ÌÓ빤³ÌÖ®¼ä£¬¶ÔÒ»¸ö¹¤³ÌµÄÐ޸ģ¬¾¡Á¿²»ÒªÒýÆðÌ«¶àÆäËû¹¤³ÌµÄ±àÒë¡£Õâ¾ÍÒªÇóÍ·Îļþ£¬»òÕß¹¤³ÌµÄÄÚÈÝÒ»¶¨Òªµ¥Ò»£¬²»ÒªÊ²Ã´¶«Î÷¶¼ÍùÀïÃæÈû£¬´Ó¶øÒýÆð²»±ØÒªµÄÒÀÀµ¡£ÕâÒ²¿ÉÒÔ˵ÊÇÄÚ¾ÛÐÔ°É¡£
ÒÔÍ·ÎļþΪÀý£¬²»Òª°ÑÁ½¸ö²»Ïà¹ØµÄÀ࣬»òÕßûʲôÁªÏµµÄºê¶¨Òå·Åµ½Ò»¸öÍ·ÎļþÀï¡£ÄÚÈÝÒª¾¡Á¿µ¥Ò»£¬´Ó¶ø²»»áʹ°üº¬ËûÃǵÄÎļþ°üº¬Á˲»ÐèÒªµÄÄÚÈÝ¡£¼ÇµÃÎÒÃÇÔø¾×ö¹ýÕâôһ¸öÊ£¬°Ñ´úÂëÖÐ×î"hot"µÄÄÇЩͷÎļþÕÒ³öÀ´£¬È»ºó·Ö³É¶à¸ö¶ÀÁ¢µÄСÎļþ£¬Ð§¹ûÏ൱¿É¹Û¡£
ÆäʵÎÒÃÇÈ¥Äê×ö¹ýµÄrefactoring£¬°ÑÖÚ¶àDLL·ÖÀë³ÉUIÓëCoreÁ½¸ö²¿·Ö£¬Ò²ÊÇÓÐ×ÅÏàͬµÄЧ¹ûµÄ - Ìá¸ß¿ª·¢Ð§ÂÊ¡£
ɾ³ýÈßÓàµÄÍ·Îļþ
һЩ´úÂë¾¹ýÉÏÊ®ÄêµÄ¿ª·¢Óëά»¤£¬¾ÊÖµÄÈËÎÞÊý£¬ºÜÓпÉÄܳöÏÖ°üº¬ÁËûÓõÄÍ·Îļþ£¬»òÖظ´°üº¬µÄÏÖÏó£¬È¥µôÕâЩÈßÓàµÄincludeÊÇÏ൱±ØÒªµÄ¡£µ±È»£¬ÕâÖ÷ÒªÊÇÕë¶ÔcppµÄ£¬ÒòΪ¶ÔÓÚÒ»¸öÍ·Îļþ£¬ÆäÖеÄij¸öincludeÊÇ·ñÈßÓàºÜÄѽ綨£¬µÃ¿´ÊÇ·ñÔÚ×îÖյıàÒëµ¥ÔªÖÐÓõ½ÁË£¬¶øÕâÑùÓÖ¿ÉÄܳöÏÖÔÚÒ»¸ö±àÒëµ¥ÔªÓõ½ÁË£¬¶øÔÚÁíÍâÒ»¸ö±àÒëµ¥ÔªÖÐûÓõ½µÄÇé¿ö¡£
֮ǰÔøд¹ýÒ»¸öPerl½Å±¾ÓÃÀ´×Ô¶¯È¥³ýÕâЩÈßÓàµÄÍ·Îļþ£¬ÔÚij¸ö¹¤³ÌÖо¹È»È¥µô¶à´ïÁË5000¶à¸öµÄinclude¡£
Ìرð×¢ÒâinlineºÍtemplate
ÕâÊÇC++ÖÐÁ½ÖֱȽÏ"ÏȽø"µÄ»úÖÆ£¬µ«ÊÇËüÃÇÈ´ÓÖÇ¿ÖÆÎÒÃÇÔÚÍ·ÎļþÖаüº¬ÊµÏÖ£¬Õâ¶ÔÔö¼ÓÍ·ÎļþµÄÄÚÈÝ£¬´Ó¶ø¼õÂý±àÒëËÙ¶ÈÓÐןܴóµÄ¹±Ïס£Ê¹ÓÃ֮ǰ£¬È¨ºâһϡ£
¶þ¡¢×ۺϼ¼ÇÉ
Ô¤±àÒëÍ·Îļþ£¨PCH£©
°ÑһЩ³£Óõ«²»³£¸Ä¶¯µÄÍ·Îļþ·ÅÔÚÔ¤±àÒëÍ·ÎļþÖС£ÕâÑù£¬ÖÁÉÙÔÚµ¥¸ö¹¤³ÌÖÐÄã²»ÐèÒªÔÚÿ¸ö±àÒëµ¥ÔªÀïÒ»±éÓÖÒ»±éµÄloadÓë½âÎöͬһ¸öÍ·ÎļþÁË¡£
Unity Build
Unity Build×ö·¨ºÜ¼òµ¥£¬°ÑËùÓеÄcpp°üº¬µ½Ò»¸öcppÖÐ(all.cpp) ,È»ºóÖ»±àÒëall.cpp¡£ÕâÑùÎÒÃǾÍÖ»ÓÐÒ»¸ö±àÒëµ¥Ôª£¬ÕâÒâζ×Ų»ÐèÒªÖظ´loadÓë½âÎöͬһ¸öÍ·ÎļþÁË£¬Í¬Ê±ÒòΪֻ²úÉúÒ»¸öobjÎļþ£¬ÔÚÁ´½ÓµÄʱºòÒ²²»ÐèÒªÄÇôÃܼ¯µÄ´ÅÅ̲Ù×÷ÁË,¹À¼ÆÄÜÓÐ10xµÄÌá¸ß£¬¿´¿´Õâ¸öÊÓƵ¸ÐÊÜÒ»ÏÂÆä×ö·¨ÓëËٶȰɡ£
ccache
compiler cache, ͨ¹ýcacheÉÏÒ»´Î±àÒëµÄ½á¹û£¬Ê¹rebuildÔÚ±£³Ö½á¹ûÏàͬµÄÇé¿öÏ£¬¼«´óµÄÌá¸ßËٶȡ£ÎÒÃÇÖªµÀÈç¹ûÊÇbuild£¬ÏµÍ³»á¶Ô±ÈÔ´´úÂëÓëÄ¿±ê´úÂëµÄʱ¼äÀ´¾ö¶¨ÊÇ·ñÒªÖØбàÒëij¸öÎļþ£¬Õâ¸ö·½·¨Æäʵ²¢²»ÍêÈ«¿É¿¿(±ÈÈç´ÓsvnÉÏÄÃÁËÉϸö°æ±¾µÄ´úÂë)£¬¶øccacheÅжϵÄÔÔòÔòÊÇÎļþµÄÄÚÈÝ£¬Ïà¶ÔÀ´½²Òª¿É¿¿µÄ¶à¡£ºÜ¿ÉϧµÄÊÇ£¬Visual StudioÏÖÔÚ»¹²»Ö§³ÖÕâ¸ö¹¦ÄÜ - ÆäʵÍêÈ«¿ÉÒÔ¼ÓÒ»¸öеÄÃüÁ±ÈÈçcache build£¬½éÓÚbuildÓërebuildÖ®¼ä£¬ÕâÑù£¬rebuild¾Í¿ÉÒÔ»ù±¾²»ÓÃÁË¡£
²»ÒªÓÐÌ«¶àµÄAdditional Include Directories
±àÒëÆ÷¶¨Î»ÄãincludeµÄÍ·Îļþ£¬ÊǸù¾ÝÄãÌṩµÄinclude directories½øÐÐËÑË÷µÄ¡£¿ÉÒÔÏëÏó£¬Èç¹ûÄãÌṩÁË100¸ö°üº¬Ä¿Â¼£¬¶øij¸öÍ·ÎļþÊÇÔÚµÚ100¸öĿ¼Ï£¬¶¨Î»ËüµÄ¹ý³ÌÊǷdz£Í´¿àµÄ¡£×éÖ¯ºÃÄãµÄ°üº¬Ä¿Â¼£¬²¢¾¡Á¿±£³Ö¼ò½à¡£
Èý¡¢±àÒë×ÊÔ´
ÒªÌá¸ßËٶȣ¬ÒªÃ´¼õÉÙÈÎÎñ£¬ÒªÃ´¼ÓÅÉÈËÊÖ£¬Ç°ÃæÁ½¸ö·½Ãæ½²µÃ¶¼ÊǼõÉÙÈÎÎñ£¬¶øÊÂʵÉÏ£¬ÔÚÌá¸ß±àÒëËÙ¶ÈÕâ¿é£¬¼ÓÅÉÈËÊÖ»¹ÊÇÓÐ×ŷdz£ÖØÒªµÄ×÷Óõġ£
²¢ÐбàÒë
Âò¸ö4ºËµÄ£¬»òÕß8ºËµÄcpu£¬Ã¿´ÎÒ»build£¬¾ÍÊÇ8¸öÎļþ²¢ÐÐ×ű࣬ÄÇËٶȣ¬¿´×Ŷ¼Ë¬¡£ ÒªÊÇÄãÃÇÀϰ岻ͬÒ⣬ÈÃËû¶Á¶ÁÕâƪÎÄÕ£ºHardware is Cheap, Programmers are Expensive
¸üºÃµÄ´ÅÅÌ
ÎÒÃÇÖªµÀ£¬±àÒëËÙ¶ÈÂýºÜ´óÒ»²¿·ÖÔÒòÊÇ´ÅÅ̲Ù×÷£¬ÄÇô³ýÁ˾¡¿ÉÄܵļõÉÙ´ÅÅ̲Ù×÷£¬ÎÒÃÇ»¹¿ÉÒÔ×öµÄ¾ÍÊǼӿì´ÅÅÌËٶȡ£±ÈÈçÉÏÃæ8¸öºËÒ»¿é¹¤×÷µÄʱºò£¬´ÅÅ̼«ÓпÉÄܳÉΪ×î´óµÄÆ¿¾±¡£Âò¸ö15000תµÄ´ÅÅÌ£¬»òÕßSSD£¬»òÕßRAID0µÄ£¬×ÜÖ®£¬Ô½¿ìÔ½ºÃ¡£
·Ö²¼Ê½±àÒë
һ̨»ú×ÓµÄÐÔÄÜʼÖÕÊÇÓÐÏ޵ģ¬ÀûÓÃÍøÂçÖпÕÏеÄcpu×ÊÔ´£¬ÒÔ¼°×¨ÃÅÓÃÀ´±àÒëµÄbuild serverÀ´°ïÖúÄã±àÒë²ÅÄÜ´Ó¸ù±¾ÉϽâ¾öÎÒÃDZàÒëËٶȵÄÎÊÌ⣬ÏëÏëÔÀ´Òªbuild 1¸ö¶àСʱ¹¤³ÌµÄÔÚ2·ÖÖÓÄÚ¾ÍÄܸ㶨£¬Äã¾ÍÖªµÀÄãÒ»¶¨²»ÄÜûÓÐËü - Incredibuild²¢ÐУ¬Æäʵ»¹¿ÉÒÔÕâô×ö¡£
ÕâÊÇÒ»¸ö±È½Ï¼«¶ËµÄÇé¿ö£¬Èç¹ûÄãÓÃÁËIncredibuild£¬¶Ô×îÖյıàÒëËٶȻ¹ÊDz»ÂúÒ⣬Ôõô°ì£¿ÆäʵֻҪÌø³ö˼άµÄ¿ò¼Ü£¬±àÒëËٶȻ¹ÊÇ¿ÉÒÔÓÐÖʵķÉÔ¾µÄ - Ç°ÌáÊÇÄãÓÐ×ã¹»¶àµÄ»úÆ÷£º
¼ÙÉèÄãÓÐsolution AºÍsolution B£¬BÒÀÀµÓÚA£¬ËùÒÔ±ØÐëÔÚAÖ®ºóBuild B¡£ÆäÖÐA£¬B Build¸÷ÐèÒª1¸öСʱ£¬ÄÇô×ܹ²Òª2¸öСʱ¡£¿ÉÊÇBÒ»¶¨ÒªÔÚAÖ®ºóbuildÂð£¿Ìø³öÕâ¸ö˼ά¿ò¼Ü£¬Äã¾ÍÓÐÁËÏÂÊö·½°¸£º
ͬʱ¿ªÊ¼build AºÍB ¡£
AµÄbuild³É¹¦£¬ÕâÀïËäÈ»BµÄbuildʧ°ÜÁË£¬µ«¶¼Ö»ÊÇʧ°ÜÔÚ×îºóµÄlinkÉÏ¡£
ÖØÐÂlink BÖеÄproject¡£
ÕâÑù£¬Í¨¹ýÈÃAµÄbuildÓëBµÄ±àÒë²¢ÐУ¬×îºólinkÒ»ÏÂBÖеÄproject£¬Õû¸ö±àÒëËÙ¶ÈÓ¦¸ÃÄܹ»¿ØÖÆÔÚ1¸öСʱ15·ÖÖÓÖ®ÄÚ¡£
ÁíÍ⣬Õâ±¾Êé̸Á˺ܶàÕâ·½ÃæµÄÄÚÈÝ£º´ó¹æÄ£C++³ÌÐòÉè¼Æ¡£