📄 lib0044.html
字号:
<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Performance Comparison</title>
<link rel="STYLESHEET" type="text/css" href="images/xpolecat.css">
<link rel="STYLESHEET" type="text/css" href="images/ie.content.books24x7.css">
</head>
<body >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<td><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle" alt="Team LiB"></a></div></td>
<td valign="top" class="v2" align="right"><div STYLE="MARGIN-RIGHT: 0.15in"><a href="LiB0043.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0045.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr>
</table>
<div class="chapter">
<a name="ch05"></a>
<div class="section">
<h2 class="first-section-title"><a name="611"></a><a name="ch05lev1sec4"></a>Performance Comparison</h2><a name="612"></a><a name="IDX-332"></a>
<p class="para">At this point, it might be enlightening to gather all of the statistics from the past two chapters together:</p>
<a name="613"></a><a name="ch05table05"></a>
<table class="table" border="1">
<caption class="table-title">
<span class="table-title"><span class="table-titlelabel">Table 5.5</span></span>
</caption>
<thead>
<tr valign="top">
<th class="th" scope="col" align="left" valign="middle">
<p class="table-para">
<b class="bold">Algorithm</b>
</p>
</th><th class="th" scope="col" align="left" valign="middle">
<p class="table-para">
<b class="bold">Time to Service 1,024 Requests</b>
</p>
</th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">bit map</p>
</td><td class="td" align="left">
<p class="table-para">856 milliseconds</p>
</td>
</tr>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">sequential fit</p>
</td><td class="td" align="left">
<p class="table-para">35 milliseconds</p>
</td>
</tr>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">segregated lists</p>
</td><td class="td" align="left">
<p class="table-para">5 milliseconds</p>
</td>
</tr>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">reference counting</p>
</td><td class="td" align="left">
<p class="table-para">30 milliseconds</p>
</td>
</tr>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">mark-sweep</p>
</td><td class="td" align="left">
<p class="table-para">430 milliseconds</p>
</td>
</tr>
</tbody>
</table>
<p class="para">Hands down, the segregated list approach is the quickest. It also wastes memory like nobody's business. It would be very easy (with the segregated list approach) to end up reserving 1,024 bytes for an 8-byte allocation request. This leaves the sequential fit algorithm as the most attractive implementation with regard to the manual memory managers presented in <a href="LiB0019.html#131" target="_parent" class="chapterjump">Chapter 2</a>.</p>
<p class="para">While the reference counting approach is actually faster than two of the manual memory managers, it also has the nasty habit of developing memory leaks when confronted with cyclic pointer references. The whole point of using a garbage collector is to avoid memory leaks, so this problem kicks reference counting out of the race. This leaves us with the mark-sweep garbage collector, which has obvious performance issues.</p>
<p class="last-para">I will spend the remainder of this book suggesting various ways to augment the mark-sweep collector's execution time and functionality. I will leave it as an exercise to the reader to augment the mark-sweep collector with these additional features.</p>
<a></a>
</div>
</div>
</div>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<td><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle" alt="Team LiB"></a></div></td>
<td valign="top" class="v2" align="right"><div STYLE="MARGIN-RIGHT: 0.15in"><a href="LiB0043.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0045.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -