亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? ch24.htm

?? Learning language of Visual C++6
?? HTM
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>

<HEAD>
<SCRIPT LANGUAGE="JavaScript">

<!--

function popUp(pPage) {
 var fullURL = document.location;
 var textURL = fullURL.toString();
 var URLlen = textURL.length;
 var lenMinusPage = textURL.lastIndexOf("/");
 lenMinusPage += 1;
 var fullPath = textURL.substring(0,lenMinusPage);
 popUpWin = window.open('','popWin','resizable=yes,scrollbars=no,width=525,height=394');
 figDoc= popUpWin.document;
 zhtm= '<HTML><HEAD><TITLE>' + pPage + '</TITLE>';
 zhtm += '<link rel="stylesheet" href="/includes/stylesheets/ebooks.css"></head>';
 zhtm += '<BODY bgcolor="#FFFFFF">';
 zhtm += '<IMG SRC="' + fullPath + pPage + '">';
 zhtm += '<P><B>' + pPage + '</B>';
 zhtm += '</BODY></HTML>';
 window.popUpWin.document.write(zhtm);
 window.popUpWin.document.close();
 // Johnny Jackson 4/28/98
 }

//-->
                                                                
</SCRIPT>
<link rel="stylesheet" href="/includes/stylesheets/ebooks.css">

	
	<TITLE>Special Edition Using Visual C++ 6 -- Ch 24 -- Improving Your Application's Performance</TITLE>
</HEAD>

<BODY TEXT="#000000" BGCOLOR="#FFFFFF">

<CENTER>
<H1><IMG SRC="../button/que.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM" BORDER="0"><BR>
Special Edition Using Visual C++ 6</H1>
</CENTER>
<CENTER>
<P><A HREF="../ch23/ch23.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"
ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch25/ch25.htm"><IMG
SRC="../button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"
BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../button/contents.gif" WIDTH="128"
HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> 
<HR>

</CENTER>
<CENTER>
<H1>- 24 -</H1>

<H1>Improving Your Application's Performance</H1>
</CENTER>

<UL>
	<LI><A HREF="#Heading1">Preventing Errors with ASSERT and TRACE</A>
	<UL>
		<LI><A HREF="#Heading2">ASSERT: Detecting Logic Errors</A>
		<LI><A HREF="#Heading3">TRACE: Isolating Problem Areas in Your Program</A>
	</UL>
	<LI><A HREF="#Heading4">Adding Debug-Only Features</A>
	<LI><A HREF="#Heading5">Sealing Memory Leaks</A>
	<UL>
		<LI><A HREF="#Heading6">Common Causes of Memory Leaks</A>
		<LI><A HREF="#Heading7">Debug new and delete</A>
		<LI><A HREF="#Heading8">Automatic Pointers</A>
	</UL>
	<LI><A HREF="#Heading9">Using Optimization to Make Efficient Code</A>
	<LI><A HREF="#Heading10">Finding Bottlenecks by Profiling</A>
</UL>

<P>
<HR SIZE="4">

<CENTER>
<H1></H1>
</CENTER>
<P>When developing a new application, there are various challenges developers must
meet. You need your application to compile, to run without blowing up, and you must
be sure that it does what you want it to do. On some projects, there is time to determine
whether your application can run faster and use less memory or whether you can have
a smaller executable file. The performance improvement techniques discussed in this
chapter can prevent your program from blowing up and eliminate the kind of thinkos
that result in a program calculating or reporting the wrong numbers. These improvements
are not merely final tweaks and touch-ups on a finished product.</P>
<P>You should form the habit of adding an ounce of prevention to your code as you
write and the habit of using the debugging capabilities that Developer Studio provides
you to confirm what's going on in your program. If you save all your testing to the
end, both the testing and the bug-fixing will be much harder than if you had been
testing all along. Also, of course, any bug you manage to prevent will never have
to be fixed at all!</P>
<P>
<H2><A NAME="Heading1"></A>Preventing Errors with ASSERT and TRACE</H2>
<P>The developers of Visual C++ did not invent the concepts of asserting and tracing.
Other languages support these ideas, and they are taught in many computer science
courses. What is exciting about the Visual C++ implementation of these concepts is
the clear way in which your results are presented and the ease with which you can
suppress assertions and TRACE statements in release versions of your application.</P>
<P>
<H3><A NAME="Heading2"></A>ASSERT: Detecting Logic Errors</H3>
<P>The ASSERT macro enables you to check a condition that you logically believe should
always be TRUE. For example, imagine you are about to access an array like this:</P>
<P>
<PRE>array[i] = 5;
</PRE>
<P>You want to be sure that the index, i, isn't less than zero and larger than the
number of elements allocated for the array. Presumably you have already written code
to calculate i, and if that code has been written properly, i must be between 0 and
the array size. An ASSERT statement will verify that:</P>
<P>
<PRE>ASSERT( i &gt; 0 &amp;&amp; i &lt; ARRAYSIZE)
</PRE>


<BLOCKQUOTE>
	<P>
<HR>
<strong>NOTE:</strong> There is no semicolon (;) at the end of the line because ASSERT is
	a macro, not a function. Older C programs may call a function named assert(), but
	you should replace these calls with the ASSERT macro because ASSERT disappears during
	a release build, as discussed later in this section.&#160;
<HR>


</BLOCKQUOTE>

<P>You can check your own logic with ASSERT statements. They should never be used
to check for user input errors or bad data in a file. Whenever the condition inside
an ASSERT statement is FALSE, program execution halts with a message telling you
which assertion failed. At this point, you know you have a logic error, or a developer
error, that you need to correct. Here's another example:</P>
<P>
<PRE>// Calling code must pass a non-null pointer 
void ProcessObject( Foo * fooObject )
{
       ASSERT( fooObject )
       // process object
}
</PRE>
<P>This code can dereference the pointer in confidence, knowing execution will be
halted if the pointer is NULL.</P>
<P>You probably already know that Developer Studio makes it simple to build debug
and release versions of your programs. The debug version #defines a constant, _DEBUG,
and macros and other pre-processor code can check this constant to determine the
build type. When _DEBUG isn't defined, the ASSERT macro does nothing. This means
there is no speed constraint in the final code, as there would be if you added if
statements yourself to test for logic errors. There is no need for you to go through
your code, removing ASSERT statements when you release your application, and, in
fact, it's better to leave them there to help the developers who work on version
2. They document your assumptions, and they'll be there when the debugging work starts
again. In addition, ASSERT can't help you if there is a problem with the release
version of your code because it is used to find logic and design errors before you
release version 1.0 of your product.</P>
<P>
<H3><A NAME="Heading3"></A>TRACE: Isolating Problem Areas in Your Program</H3>
<P>As discussed in Appendix D, &quot;Debugging,&quot; the power of the Developer
Studio debugger is considerable. You can step through your code one line at a time
or run to a breakpoint, and you can see any of your variables' values in watch windows
as you move through the code. This can be slow, however, and many developers use
TRACE statements as a way of speeding up this process and zeroing in on the problem
area. Then they turn to more traditional step-by-step debugging to isolate the bad
code.</P>
<P>In the old days, isolating bad code meant adding lots of print statements to your
program, which is problematic in a Windows application. Before you start to think
up workarounds, such as printing to a file, relax. The TRACE macro does everything
you want, and like ASSERT, it magically goes away in release builds.</P>
<P>There are several TRACE macros: TRACE, TRACE0, TRACE1, TRACE2, and TRACE3. The
number-suffix indicates the number of parametric arguments beyond a simple string,
working much like printf. The different versions of TRACE were implemented to save
data segment space.</P>
<P>When you generate an application with AppWizard, many ASSERT and TRACE statements
are added for you. Here's a TRACE example:</P>
<P>
<PRE>if (!m_wndToolBar.Create(this)
    || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
    TRACE0(&quot;Failed to create toolbar\n&quot;);
    return -1;      // fail to create
}
</PRE>
<P>If the creation of the toolbar fails, this routine will return -1, which signals
to the calling program that something is wrong. This will happen in both debug and
release builds. In debug builds, though, a trace output will be sent to help the
programmer understand what went wrong.</P>
<P>All the TRACE macros write to afxDump, which is usually the debug window, but
can be set to stderr for console applications. The number-suffix indicates the parametric
argument count, and you use the parametric values within the string to indicate the
passed data type--for example, to send a TRACE statement that includes the value
of an integer variable:</P>
<P>
<PRE>TRACE1(&quot;Error Number: %d\n&quot;, -1 );
</PRE>
<P>or to pass two arguments, maybe a string and an integer:</P>
<P>
<PRE>TRACE2(&quot;File Error %s, error number: %d\n&quot;, __FILE__, -1 );
</PRE>
<P>The most difficult part of tracing is making it a habit. Sprinkle TRACE statements
anywhere you return error values: before ASSERT statements and in areas where you
are unsure that you constructed your code correctly. When confronted with unexpected
behavior, add TRACE statements first so that you better understand what is going
on before you start debugging.</P>
<P>
<H2><A NAME="Heading4"></A>Adding Debug-Only Features</H2>
<P>If the idea of code that isn't included in a release build appeals to you, you
may want to arrange for some of your own code to be included in debug builds but
not in release builds. It's easy. Just wrap the code in a test of the _DEBUG constant,
like this:</P>
<P>
<PRE>#ifdef _DEBUG
    // debug code here
#endif
</PRE>
<P>In release builds, this code will not be compiled at all.</P>
<P>All the settings and configurations of the compiler and linker are kept separately
for debug and release builds and can be changed independently. For example, many
developers use different compiler warning levels. To bump your warning level to 4
for debug builds only, follow these steps:</P>
<P>

<DL>
	<DT></DT>
	<DD><B>1. </B>Choose Project, Settings, which opens the Project Settings dialog box,
	shown in Figure 24.1.
	<P>
	<DT></DT>
	<DD><B>2. </B>Choose Debug or Release from the drop-down list box at the upper left.
	If you choose All Configurations, you'll change debug and release settings simultaneously.
	<P>
	<DT></DT>
	<DD><B>3. </B>Click the C/C++ tab and set the Warning Level to Level 4, as shown
	in Figure 24.2. The default is Level 3, which you will use for the release version
	(see Figure 24.3).
	<P>
</DL>

<P>Warning level 4 will generate a lot more errors than level 3. Some of those errors
will probably come from code you didn't even write, such as MFC functions. You'll
just have to ignore those warnings.</P>
<P><A HREF="javascript:popUp('24uvc01.gif')"><B>FIG. 24.1</B></A><B> </B><I>The Project
Settings dialog box enables you to set configuration items for different phases of
development.</I></P>

<P><A HREF="javascript:popUp('24uvc02.gif')"><B>FIG. 24.2</B></A><B> </B><I>Warning
levels can be set higher during development.</I></P>

<P><A HREF="javascript:popUp('24uvc03.gif')"><B>FIG. 24.3</B></A><B> </B><I>Warning
levels are usually lower in a production release.</I></P>

<P><I></I>
<H2><A NAME="Heading5"></A>Sealing Memory Leaks</H2>
<P>A memory leak can be the most pernicious of errors. Small leaks may not cause
any execution errors in your program until it is run for an exceptionally long time
or with a larger-than-usual data file. Because most programmers test with tiny data
files or run the program for only a few minutes when they are experimenting with
parts of it, memory leaks may not reveal themselves in everyday testing. Alas, memory
leaks may well reveal themselves to your users when the program crashes or otherwise
misbehaves.</P>
<P>
<H3><A NAME="Heading6"></A>Common Causes of Memory Leaks</H3>
<P>What does it mean when your program has a memory leak? It means that your program
allocated memory and never released it. One very simple cause is calling new to allocate
an object or an array of objects on the heap and never calling delete. Another cause
is changing the pointer kept in a variable without deleting the memory the pointer
was pointing to. More subtle memory leaks arise when a class with a pointer as a
member variable calls new to assign the pointer but doesn't have a copy constructor,
assignment operator, or destructor. Listing 24.1 illustrates some ways that memory
leaks are caused.</P>
<P>
<H4>Listing 24.1&#160;&#160;Causing Memory Leaks</H4>
<PRE>// simple pointer leaving scope
{
  int * one = new int;
  *one = 1;
} // one is out of scope now, and wasn't deleted
// mismatched new and delete: new uses delete and new[] uses delete[]

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本道在线观看一区二区| 国产精品毛片a∨一区二区三区| 一本色道久久加勒比精品| 成人黄页毛片网站| 99久久综合狠狠综合久久| av成人免费在线| 94-欧美-setu| 一本大道久久a久久综合婷婷| 一本到不卡免费一区二区| 色综合久久久久网| 欧美视频一区二区三区在线观看| 色吧成人激情小说| 欧美精品一二三四| 精品理论电影在线观看| 国产午夜精品一区二区三区视频 | 国产精品视频在线看| 国产精品视频免费看| 亚洲欧美另类在线| 一区二区三区91| 轻轻草成人在线| 国产一区二区毛片| av电影天堂一区二区在线| 色狠狠色噜噜噜综合网| 宅男在线国产精品| 久久奇米777| 中文字幕一区二区在线观看| 伊人开心综合网| 日韩激情中文字幕| 国产精品伊人色| 日本久久精品电影| 欧美一级搡bbbb搡bbbb| 久久精品亚洲精品国产欧美| 亚洲色图视频网| 日韩国产欧美一区二区三区| 国产成人啪免费观看软件| 色婷婷国产精品久久包臀| 4438成人网| 中文在线一区二区| 午夜激情一区二区三区| 国产一区二区三区四区五区入口| 99久久国产免费看| 日韩一级高清毛片| 中文字幕一区二区三区视频| 五月天久久比比资源色| 国产98色在线|日韩| 欧美午夜精品免费| 国产欧美一区在线| 五月天国产精品| 成人精品国产免费网站| 91精品久久久久久久久99蜜臂| 国产香蕉久久精品综合网| 天堂成人国产精品一区| 国产福利一区在线| 91精品久久久久久久久99蜜臂 | 丁香网亚洲国际| 欧美日韩精品高清| 国产精品麻豆99久久久久久| 水蜜桃久久夜色精品一区的特点| 国产成a人亚洲| 91精品国产入口在线| 亚洲视频一区二区在线| 日韩**一区毛片| 欧洲国内综合视频| 中文一区二区在线观看| 蜜芽一区二区三区| 欧美日韩在线不卡| 亚洲女性喷水在线观看一区| 黄色成人免费在线| 欧美一级日韩免费不卡| 亚洲国产婷婷综合在线精品| 不卡在线视频中文字幕| 久久综合一区二区| 日本一不卡视频| 欧美日韩一区二区不卡| 亚洲欧美日韩国产另类专区 | 国产无一区二区| 久久99精品国产.久久久久久| 91黄色激情网站| 国产精品美女久久久久久久网站| 久久草av在线| 日韩欧美在线观看一区二区三区| 亚洲福利视频一区二区| 一道本成人在线| 亚洲免费av观看| 99久久国产综合精品女不卡| 国产精品视频麻豆| 国产盗摄一区二区| 国产网红主播福利一区二区| 国内精品视频一区二区三区八戒| 69久久99精品久久久久婷婷| 亚洲第一会所有码转帖| 欧美亚洲尤物久久| 亚洲一区二区三区在线看| 色噜噜狠狠成人中文综合 | 国产精品91一区二区| 亚洲精品在线三区| 国产美女娇喘av呻吟久久| 国产欧美一区二区三区鸳鸯浴 | 日韩欧美一区二区在线视频| 五月天婷婷综合| 91精品国产乱| 秋霞影院一区二区| 正在播放亚洲一区| 日产欧产美韩系列久久99| 在线电影院国产精品| 日本亚洲天堂网| 精品伦理精品一区| 国产成人av资源| 中文字幕一区二区三区蜜月| 色诱视频网站一区| 亚瑟在线精品视频| 日韩免费高清电影| 国产精品一二三区| 国产精品视频线看| 在线观看视频欧美| 日韩av一二三| 国产婷婷一区二区| 色婷婷av一区二区三区软件| 亚洲国产中文字幕| 欧美xxxxxxxxx| 大胆欧美人体老妇| 一区二区三区在线观看国产 | 国产精品久久看| 91电影在线观看| 蜜臂av日日欢夜夜爽一区| 久久久久久久久久久黄色| eeuss国产一区二区三区| 亚洲六月丁香色婷婷综合久久| 欧美日韩黄视频| 激情综合网最新| 成人欧美一区二区三区在线播放| 欧美在线观看视频一区二区三区 | 91麻豆国产香蕉久久精品| 亚洲精品视频在线观看免费 | 亚洲男人都懂的| 欧美一区二区三区在线观看视频| 国产一区二区按摩在线观看| 国产精品久久看| 91 com成人网| 国产一区二区免费看| 亚洲精品高清视频在线观看| 欧美一级午夜免费电影| 成人av在线资源网站| 午夜精品国产更新| 国产精品视频第一区| 欧美猛男男办公室激情| 国产999精品久久久久久绿帽| 亚洲高清不卡在线| 久久色.com| 欧美日韩一区视频| 国产98色在线|日韩| 亚洲1区2区3区4区| 国产精品国产自产拍高清av | 美女视频黄 久久| 一色桃子久久精品亚洲| 日韩欧美一区二区不卡| a美女胸又www黄视频久久| 亚洲国产欧美一区二区三区丁香婷| 精品免费日韩av| 欧美亚洲自拍偷拍| 成人免费观看视频| 久久99精品国产麻豆婷婷 | 色综合久久九月婷婷色综合| 玖玖九九国产精品| 亚洲一区二区三区美女| 久久影院视频免费| 91麻豆精品国产91久久久久久久久| 成人国产精品视频| 麻豆精品一二三| 亚洲国产日韩一级| 中文字幕一区二区三区精华液| 精品国产伦一区二区三区免费 | 久久免费看少妇高潮| 欧美日韩精品一二三区| 色综合久久综合| 北条麻妃国产九九精品视频| 久久精品72免费观看| 午夜天堂影视香蕉久久| ㊣最新国产の精品bt伙计久久| 久久亚洲精品小早川怜子| 日韩三级免费观看| 欧美日韩国产bt| 91成人在线精品| 91丨porny丨首页| 高清在线观看日韩| 国产激情视频一区二区在线观看| 日本sm残虐另类| 亚洲电影视频在线| 亚洲黄一区二区三区| 中文字幕一区二区5566日韩| 国产午夜亚洲精品不卡| 久久在线免费观看| 久久这里只有精品6| 久久综合五月天婷婷伊人| 欧美哺乳videos| 欧美va天堂va视频va在线| 欧美日韩aaaaaa| 欧美猛男超大videosgay| 91久久奴性调教| 日本韩国欧美一区二区三区|