You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

385 lines
13 KiB
HTML

<!-- HTML header for doxygen 1.8.7-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.6.3"/>
<!--BEGIN PROJECT_NAME--><title>avr-libc: avr-libc: Benchmarks</title><!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME--><title>avr-libc: Benchmarks</title><!--END !PROJECT_NAME-->
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="$relpath^jquery.js"></script>
<script type="text/javascript" src="$relpath^dynsections.js"></script>
$treeview
$search
$mathjax
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
$extrastylesheet
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<!--BEGIN TITLEAREA-->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<!--BEGIN PROJECT_LOGO-->
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo"/></td>
<!--END PROJECT_LOGO-->
<!--BEGIN PROJECT_NAME-->
<td style="padding-left: 0.5em;">
<div id="projectname">avr-libc
<!--BEGIN PROJECT_NUMBER-->&#160;<span id="projectnumber">2.0.0</span><!--END PROJECT_NUMBER-->
</div>
<!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
</td>
<!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME-->
<!--BEGIN PROJECT_BRIEF-->
<td style="padding-left: 0.5em;">
<div id="projectbrief">$projectbrief</div>
</td>
<!--END PROJECT_BRIEF-->
<!--END !PROJECT_NAME-->
<!--BEGIN DISABLE_INDEX-->
<!--BEGIN SEARCHENGINE-->
<td>$searchbox</td>
<!--END SEARCHENGINE-->
<!--END DISABLE_INDEX-->
</tr>
</tbody>
</table>
<table>
<tr>
<td align="left"><a href="http://www.nongnu.org/avr-libc/"><h2>AVR Libc Home Page</h2></a></td>
<td align="center" colspan=4><img src="avrs.png" alt="AVRs" align="middle" border="0"></td>
<td align="right"><a href="https://savannah.nongnu.org/projects/avr-libc/"><h2>AVR Libc Development Pages</h2></a></td>
</tr>
<tr>
<td align="center" width="20%"><a href="index.html"><h2>Main Page</h2></a></td>
<td align="center" width="20%"><a href="pages.html"><h2>User Manual</h2></a></td>
<td align="center" width="20%"><a href="modules.html"><h2>Library Reference</h2></a></td>
<td align="center" width="20%"><a href="FAQ.html"><h2>FAQ</h2></a></td>
<td align="center" width="20%"><a href="group__demos.html"><h2>Example Projects</h2></a></td>
</tr>
</table>
</div>
<!--END TITLEAREA-->
<!-- end header part -->
<!-- Generated by Doxygen 1.6.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="contents">
<h1><a class="anchor" id="benchmarks">Benchmarks </a></h1><p>The results below can only give a rough estimate of the resources necessary for using certain library functions. There is a number of factors which can both increase or reduce the effort required:</p>
<ul>
<li>Expenses for preparation of operands and their stack are not considered.</li>
</ul>
<ul>
<li>In the table, the size includes all additional functions (for example, function to multiply two integers) but they are only linked from the library.</li>
</ul>
<ul>
<li>Expenses of time of performance of some functions essentially depend on parameters of a call, for example, <a class="el" href="group__avr__stdlib.html#gafd4bf2faec43342e7ad3d2ab37bac1fe">qsort()</a> is recursive, and <a class="el" href="group__avr__stdio.html#ga6017094d9fd800fa02600d35399f2a2a">sprintf()</a> receives parameters in a stack.</li>
</ul>
<ul>
<li>Different versions of the compiler can give a significant difference in code size and execution time. For example, the <a class="el" href="group__avr__stdlib.html#ga6c140bdd3b9bd740a1490137317caa44">dtostre()</a> function, compiled with avr-gcc 3.4.6, requires 930 bytes. After transition to avr-gcc 4.2.3, the size become 1088 bytes.</li>
</ul>
<h2><a class="anchor" id="bench_libc">
A few of libc functions.</a></h2>
<p>Avr-gcc version is 4.7.1</p>
<p>The size of function is given in view of all picked up functions. By default Avr-libc is compiled with <code>-mcall-prologues</code> option. In brackets the size without taking into account modules of a prologue and an epilogue is resulted. Both of the size can coincide, if function does not cause a prologue/epilogue.</p>
<p><small> </p>
<table class="doxtable">
<tr>
<td width="50%"><b>Function</b> </td><td width="20%"><b>Units</b> </td><td width="10%"><b>Avr2</b> </td><td width="10%"><b>Avr25</b> </td><td width="10%"><b>Avr4</b> </td></tr>
<tr>
<td>atoi ("12345") </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>82 (82)<br/>
2<br/>
155 </td><td>78 (78)<br/>
2<br/>
149 </td><td>74 (74)<br/>
2<br/>
149 </td></tr>
<tr>
<td>atol ("12345") </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>122 (122)<br/>
2<br/>
221 </td><td>118 (118)<br/>
2<br/>
219 </td><td>118 (118)<br/>
2<br/>
219 </td></tr>
<tr>
<td>dtostre (1.2345, s, 6, 0) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>1116 (1004)<br/>
17<br/>
1247 </td><td>1048 (938)<br/>
17<br/>
1105 </td><td>1048 (938)<br/>
17<br/>
1105 </td></tr>
<tr>
<td>dtostrf (1.2345, 15, 6, s) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>1616 (1616)<br/>
38<br/>
1634 </td><td>1508 (1508)<br/>
38<br/>
1462 </td><td>1508 (1508)<br/>
38<br/>
1462 </td></tr>
<tr>
<td>itoa (12345, s, 10) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>110 (110)<br/>
2<br/>
879 </td><td>102 (102)<br/>
2<br/>
875 </td><td>102 (102)<br/>
2<br/>
875 </td></tr>
<tr>
<td>ltoa (12345L, s, 10) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>134 (134)<br/>
2<br/>
1597 </td><td>126 (126)<br/>
2<br/>
1593 </td><td>126 (126)<br/>
2<br/>
1593 </td></tr>
<tr>
<td>malloc (1) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>768 (712)<br/>
6<br/>
215 </td><td>714 (660)<br/>
6<br/>
201 </td><td>714 (660)<br/>
6<br/>
201 </td></tr>
<tr>
<td>realloc ((void *)0, 1) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>1284 (1172)<br/>
18<br/>
305 </td><td>1174 (1064)<br/>
18<br/>
286 </td><td>1174 (1064)<br/>
18<br/>
286 </td></tr>
<tr>
<td>qsort (s, sizeof(s), 1, cmp) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>1252 (1140)<br/>
42<br/>
21996 </td><td>1022 (912)<br/>
42<br/>
19905 </td><td>1028 (918)<br/>
42<br/>
17541 </td></tr>
<tr>
<td>sprintf_min (s, "%d", 12345) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>1224 (1112)<br/>
53<br/>
1841 </td><td>1092 (982)<br/>
53<br/>
1694 </td><td>1088 (978)<br/>
53<br/>
1689 </td></tr>
<tr>
<td>sprintf (s, "%d", 12345) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>1614 (1502)<br/>
58<br/>
1647 </td><td>1476 (1366)<br/>
58<br/>
1552 </td><td>1454 (1344)<br/>
58<br/>
1547 </td></tr>
<tr>
<td>sprintf_flt (s, "%e", 1.2345) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>3228 (3116)<br/>
67<br/>
2573 </td><td>2990 (2880)<br/>
67<br/>
2311 </td><td>2968 (2858)<br/>
67<br/>
2311 </td></tr>
<tr>
<td>sscanf_min ("12345", "%d", &amp;i) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>1532 (1420)<br/>
55<br/>
1607 </td><td>1328 (1218)<br/>
55<br/>
1446 </td><td>1328 (1218)<br/>
55<br/>
1446 </td></tr>
<tr>
<td>sscanf ("12345", "%d", &amp;i) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>2008 (1896)<br/>
55<br/>
1610 </td><td>1748 (1638)<br/>
55<br/>
1449 </td><td>1748 (1638)<br/>
55<br/>
1449 </td></tr>
<tr>
<td>sscanf ("point,color", "%[a-z]", s) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>2008 (1896)<br/>
86<br/>
3067 </td><td>1748 (1638)<br/>
86<br/>
2806 </td><td>1748 (1638)<br/>
86<br/>
2806 </td></tr>
<tr>
<td>sscanf_flt ("1.2345", "%e", &amp;x) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>3464 (3352)<br/>
71<br/>
2497 </td><td>3086 (2976)<br/>
71<br/>
2281 </td><td>3070 (2960)<br/>
71<br/>
2078 </td></tr>
<tr>
<td>strtod ("1.2345", &amp;p) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>1632 (1520)<br/>
20<br/>
1235 </td><td>1536 (1426)<br/>
20<br/>
1177 </td><td>1480 (1480)<br/>
21<br/>
1124 </td></tr>
<tr>
<td>strtol ("12345", &amp;p, 0) </td><td>Flash bytes<br/>
Stack bytes<br/>
MCU clocks </td><td>918 (806)<br/>
22<br/>
956 </td><td>834 (724)<br/>
22<br/>
891 </td><td>792 (792)<br/>
28<br/>
794 </td></tr>
</table>
<p></small></p>
<h2><a class="anchor" id="bench_libm">
Math functions.</a></h2>
<p>The table contains the number of MCU clocks to calculate a function with a given argument(s). The main reason of a big difference between Avr2 and Avr4 is a hardware multiplication.</p>
<table class="doxtable">
<tr>
<td width="50%"><b>Function</b> </td><td width="25%"><b>Avr2</b> </td><td width="25%"><b>Avr4</b> </td></tr>
<tr>
<td>__addsf3 (1.234, 5.678) </td><td>113 </td><td>108 </td></tr>
<tr>
<td>__mulsf3 (1.234, 5.678) </td><td>375 </td><td>138 </td></tr>
<tr>
<td>__divsf3 (1.234, 5.678) </td><td>466 </td><td>465 </td></tr>
<tr>
<td>acos (0.54321) </td><td>4411 </td><td>2455 </td></tr>
<tr>
<td>asin (0.54321) </td><td>4517 </td><td>2556 </td></tr>
<tr>
<td>atan (0.54321) </td><td>4710 </td><td>2271 </td></tr>
<tr>
<td>atan2 (1.234, 5.678) </td><td>5270 </td><td>2857 </td></tr>
<tr>
<td>cbrt (1.2345) </td><td>2684 </td><td>2555 </td></tr>
<tr>
<td>ceil (1.2345) </td><td>177 </td><td>177 </td></tr>
<tr>
<td>cos (1.2345) </td><td>3387 </td><td>1671 </td></tr>
<tr>
<td>cosh (1.2345) </td><td>4922 </td><td>2979 </td></tr>
<tr>
<td>exp (1.2345) </td><td>4708 </td><td>2765 </td></tr>
<tr>
<td>fdim (5.678, 1.234) </td><td>111 </td><td>111 </td></tr>
<tr>
<td>floor (1.2345) </td><td>180 </td><td>180 </td></tr>
<tr>
<td>fmax (1.234, 5.678) </td><td>39 </td><td>37 </td></tr>
<tr>
<td>fmin (1.234, 5.678) </td><td>35 </td><td>35 </td></tr>
<tr>
<td>fmod (5.678, 1.234) </td><td>131 </td><td>131 </td></tr>
<tr>
<td>frexp (1.2345, 0) </td><td>42 </td><td>41 </td></tr>
<tr>
<td>hypot (1.234, 5.678) </td><td>1341 </td><td>866 </td></tr>
<tr>
<td>ldexp (1.2345, 6) </td><td>42 </td><td>42 </td></tr>
<tr>
<td>log (1.2345) </td><td>4142 </td><td>2134 </td></tr>
<tr>
<td>log10 (1.2345) </td><td>4498 </td><td>2260 </td></tr>
<tr>
<td>modf (1.2345, 0) </td><td>433 </td><td>429 </td></tr>
<tr>
<td>pow (1.234, 5.678) </td><td>9293 </td><td>5047 </td></tr>
<tr>
<td>round (1.2345) </td><td>150 </td><td>150 </td></tr>
<tr>
<td>sin (1.2345) </td><td>3353 </td><td>1653 </td></tr>
<tr>
<td>sinh (1.2345) </td><td>4946 </td><td>3003 </td></tr>
<tr>
<td>sqrt (1.2345) </td><td>494 </td><td>492 </td></tr>
<tr>
<td>tan (1.2345) </td><td>4381 </td><td>2426 </td></tr>
<tr>
<td>tanh (1.2345) </td><td>5126 </td><td>3173 </td></tr>
<tr>
<td>trunc (1.2345) </td><td>178 </td><td>178 </td></tr>
</table>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<!-- HTML footer for doxygen 1.8.7-->
<!-- start footer part -->
<!--BEGIN GENERATE_TREEVIEW-->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
$navpath
<li class="footer">$generatedby
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="$relpath^doxygen.png" alt="doxygen"/></a> 1.6.3 </li>
</ul>
</div>
<!--END GENERATE_TREEVIEW-->
<!--BEGIN !GENERATE_TREEVIEW-->
<hr class="footer"/><address class="footer"><small>
$generatedby &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="$relpath^doxygen.png" alt="doxygen"/>
</a> 1.6.3
</small></address>
<!--END !GENERATE_TREEVIEW-->
</body>
</html>