1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Performance</title> 6<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="../metaparse.html" title="Chapter 24. Boost.Metaparse"> 10<link rel="prev" href="versioning.html" title="Versioning"> 11<link rel="next" href="the_design_of_the_library.html" title="The design of the library"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> 16<td align="center"><a href="../../../index.html">Home</a></td> 17<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="versioning.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../metaparse.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="the_design_of_the_library.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="section"> 27<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 28<a name="metaparse.performance"></a><a class="link" href="performance.html" title="Performance">Performance</a> 29</h2></div></div></div> 30<div class="toc"><dl class="toc"> 31<dt><span class="section"><a href="performance.html#metaparse.performance.benchmarks_of_boost_metaparse_st">Benchmarks 32 of BOOST_METAPARSE_STRING</a></span></dt> 33<dt><span class="section"><a href="performance.html#metaparse.performance.measuring_printf">Measuring printf</a></span></dt> 34<dt><span class="section"><a href="performance.html#metaparse.performance.further_measurements">Further measurements</a></span></dt> 35</dl></div> 36<div class="section"> 37<div class="titlepage"><div><div><h3 class="title"> 38<a name="metaparse.performance.benchmarks_of_boost_metaparse_st"></a><a name="BOOST_METAPARSE_STRING_benchmark"></a><a class="link" href="performance.html#metaparse.performance.benchmarks_of_boost_metaparse_st" title="Benchmarks of BOOST_METAPARSE_STRING">Benchmarks 39 of BOOST_METAPARSE_STRING</a> 40</h3></div></div></div> 41<div class="toc"><dl class="toc"> 42<dt><span class="section"><a href="performance.html#metaparse.performance.benchmarks_of_boost_metaparse_st.increasing_string_length">Increasing 43 string length</a></span></dt> 44<dt><span class="section"><a href="performance.html#metaparse.performance.benchmarks_of_boost_metaparse_st.increasing_number_of_strings">Increasing 45 number of strings</a></span></dt> 46<dt><span class="section"><a href="performance.html#metaparse.performance.benchmarks_of_boost_metaparse_st.increasing_string_length_limit">Increasing 47 string length limit</a></span></dt> 48</dl></div> 49<p> 50 Measurements related to the performance of the <a class="link" href="reference.html#BOOST_METAPARSE_STRING"><code class="computeroutput"><span class="identifier">BOOST_METAPARSE_STRING</span></code></a> macro. 51 </p> 52<div class="section"> 53<div class="titlepage"><div><div><h4 class="title"> 54<a name="metaparse.performance.benchmarks_of_boost_metaparse_st.increasing_string_length"></a><a class="link" href="performance.html#metaparse.performance.benchmarks_of_boost_metaparse_st.increasing_string_length" title="Increasing string length">Increasing 55 string length</a> 56</h4></div></div></div> 57<p> 58 128 strings with increasing length. Measured on a Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty 59 host with 16 GB memory. Compiler used: gcc 4.8.5. 60 </p> 61<p> 62 <span class="inlinemediaobject"><img src="../images/metaparse/length128_gcc_4.8.5.png" width="100%"></span> 63 </p> 64</div> 65<div class="section"> 66<div class="titlepage"><div><div><h4 class="title"> 67<a name="metaparse.performance.benchmarks_of_boost_metaparse_st.increasing_number_of_strings"></a><a class="link" href="performance.html#metaparse.performance.benchmarks_of_boost_metaparse_st.increasing_number_of_strings" title="Increasing number of strings">Increasing 68 number of strings</a> 69</h4></div></div></div> 70<p> 71 Increasing number of strings with 64 length. Measured on a Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty 72 host with 16 GB memory. Compiler used: gcc 4.8.5. 73 </p> 74<p> 75 <span class="inlinemediaobject"><img src="../images/metaparse/number_gcc_4.8.5.png" width="100%"></span> 76 </p> 77</div> 78<div class="section"> 79<div class="titlepage"><div><div><h4 class="title"> 80<a name="metaparse.performance.benchmarks_of_boost_metaparse_st.increasing_string_length_limit"></a><a class="link" href="performance.html#metaparse.performance.benchmarks_of_boost_metaparse_st.increasing_string_length_limit" title="Increasing string length limit">Increasing 81 string length limit</a> 82</h4></div></div></div> 83<p> 84 100 one character long strings with increasing maximum length. Measured 85 on a Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty host with 86 16 GB memory. Compiler used: gcc 4.8.5. 87 </p> 88<p> 89 <span class="inlinemediaobject"><img src="../images/metaparse/max_length_gcc_4.8.5.png" width="100%"></span> 90 </p> 91</div> 92</div> 93<div class="section"> 94<div class="titlepage"><div><div><h3 class="title"> 95<a name="metaparse.performance.measuring_printf"></a><a class="link" href="performance.html#metaparse.performance.measuring_printf" title="Measuring printf">Measuring printf</a> 96</h3></div></div></div> 97<p> 98 Parsers work at compile-time, thus their performance affects compilation 99 speed. This section shows measurements of compilation time using Metaparse. 100 The measurements were done on a Linux laptop with an 1.6 GHz Atom processor 101 and 1 GB memory. The measurements were done using GCC 4.6.1 with <code class="computeroutput"><span class="special">-</span><span class="identifier">std</span><span class="special">=</span><span class="identifier">c</span><span class="special">++</span><span class="number">0</span><span class="identifier">x</span></code> and no optimisation. Compilation speed 102 was measured using the <code class="computeroutput"><span class="identifier">time</span></code> 103 utility. 104 </p> 105<p> 106 To measure a non-trivial parser, the <code class="computeroutput"><span class="identifier">printf</span></code> 107 example program were used for measurements. Here is a list of the <code class="computeroutput"><span class="identifier">printf</span></code> calls and their compilation speed 108 (<code class="computeroutput"><span class="identifier">user</span></code> output of <code class="computeroutput"><span class="identifier">time</span></code>): 109 </p> 110<div class="table"> 111<a name="metaparse.performance.measuring_printf.printf_compilation_speed"></a><p class="title"><b>Table 24.1. Printf compilation speed</b></p> 112<div class="table-contents"><table class="table" summary="Printf compilation speed"> 113<colgroup> 114<col> 115<col> 116</colgroup> 117<thead><tr> 118<th> 119 <p> 120 type-safe <code class="computeroutput"><span class="identifier">printf</span></code> 121 call 122 </p> 123 </th> 124<th> 125 <p> 126 Compilation speed (s) 127 </p> 128 </th> 129</tr></thead> 130<tbody> 131<tr> 132<td> 133 <p> 134 No compile-time parsing (just the includes and an empty <code class="computeroutput"><span class="identifier">main</span></code>) 135 </p> 136 </td> 137<td> 138 <p> 139 3.51 140 </p> 141 </td> 142</tr> 143<tr> 144<td> 145 <p> 146 <code class="computeroutput"><span class="identifier">printf</span><span class="special"><</span><span class="identifier">BOOST_METAPARSE_STRING</span><span class="special">(</span><span class="string">"%f"</span><span class="special">)>(</span><span class="number">1.0</span><span class="special">)</span></code> 147 </p> 148 </td> 149<td> 150 <p> 151 4.95 152 </p> 153 </td> 154</tr> 155<tr> 156<td> 157 <p> 158 <code class="computeroutput"><span class="identifier">printf</span><span class="special"><</span><span class="identifier">BOOST_METAPARSE_STRING</span><span class="special">(</span><span class="string">"%f%f"</span><span class="special">)>(</span><span class="number">1.0</span><span class="special">,</span> <span class="number">2.0</span><span class="special">)</span></code> 159 </p> 160 </td> 161<td> 162 <p> 163 5.26 164 </p> 165 </td> 166</tr> 167<tr> 168<td> 169 <p> 170 <code class="computeroutput"><span class="identifier">printf</span><span class="special"><</span><span class="identifier">BOOST_METAPARSE_STRING</span><span class="special">(</span><span class="string">"%f%f%f"</span><span class="special">)>(</span><span class="number">1.0</span><span class="special">,</span> <span class="number">2.0</span><span class="special">,</span> <span class="number">3.0</span><span class="special">)</span></code> 171 </p> 172 </td> 173<td> 174 <p> 175 5.50 176 </p> 177 </td> 178</tr> 179<tr> 180<td> 181 <p> 182 <code class="computeroutput"><span class="identifier">printf</span><span class="special"><</span><span class="identifier">BOOST_METAPARSE_STRING</span><span class="special">(</span><span class="string">"%f%f%f%f"</span><span class="special">)>(</span><span class="number">1.0</span><span class="special">,</span> <span class="number">2.0</span><span class="special">,</span> <span class="number">3.0</span><span class="special">,</span> <span class="number">4.0</span><span class="special">)</span></code> 183 </p> 184 </td> 185<td> 186 <p> 187 5.82 188 </p> 189 </td> 190</tr> 191<tr> 192<td> 193 <p> 194 <code class="computeroutput"><span class="identifier">printf</span><span class="special"><</span><span class="identifier">BOOST_METAPARSE_STRING</span><span class="special">(</span><span class="string">"%f%f%f%f%f"</span><span class="special">)>(</span><span class="number">1.0</span><span class="special">,</span> <span class="number">2.0</span><span class="special">,</span> <span class="number">3.0</span><span class="special">,</span> <span class="number">4.0</span><span class="special">,</span> <span class="number">5.0</span><span class="special">)</span></code> 195 </p> 196 </td> 197<td> 198 <p> 199 6.07 200 </p> 201 </td> 202</tr> 203</tbody> 204</table></div> 205</div> 206<br class="table-break"> 207</div> 208<div class="section"> 209<div class="titlepage"><div><div><h3 class="title"> 210<a name="metaparse.performance.further_measurements"></a><a class="link" href="performance.html#metaparse.performance.further_measurements" title="Further measurements">Further measurements</a> 211</h3></div></div></div> 212<p> 213 Further measurements can be found in the following paper: 214 </p> 215<p> 216 Zoltán Porkoláb, Ábel Sinkovics: <br> <span class="bold"><strong>Domain-specific 217 Language Integration with Compile-time Parser Generator Library</strong></span> 218 <br> In Eelco Visser, Jaakko Järvi, editors, Proceedings of the ninth 219 international conference on Generative programming and component engineering 220 (GPCE 2010). ACM, October 2010, pp. 137-146. 221 </p> 222</div> 223</div> 224<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 225<td align="left"></td> 226<td align="right"><div class="copyright-footer">Copyright © 2015 Abel Sinkovics<p> 227 Distributed under the Boost Software License, Version 1.0. (See accompanying 228 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 229 </p> 230</div></td> 231</tr></table> 232<hr> 233<div class="spirit-nav"> 234<a accesskey="p" href="versioning.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../metaparse.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="the_design_of_the_library.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> 235</div> 236</body> 237</html> 238