1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Boost.Convert Overhead</title> 5<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../index.html" title="Chapter 1. Boost.Convert 2.0"> 8<link rel="up" href="../performance.html" title="Performance"> 9<link rel="prev" href="../performance.html" title="Performance"> 10<link rel="next" href="the_bigger_picture.html" title="The Bigger Picture"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="../performance.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../performance.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_bigger_picture.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="boost_convert.performance.boost_convert_overhead"></a><a class="link" href="boost_convert_overhead.html" title="Boost.Convert Overhead">Boost.Convert 28 Overhead</a> 29</h3></div></div></div> 30<p> 31 <span class="emphasis"><em>Boost.Convert</em></span> framework adds an additional layer of 32 indirection and some <span class="emphasis"><em>Boost.Convert</em></span> converters are wrappers 33 around actual conversion facilities such as <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lexical_cast</span></code>, 34 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span></code>, etc. Consequently, there might 35 be reasonable concerns with regard to the performance overhead introduced 36 by the framework as opposed to deploying conversion facilities directly. 37 </p> 38<p> 39 To test that code has been borrowed and adapted from the Spirit.Qi performance/optimization 40 framework (see $BOOST_ROOT/libs/spirit/workbench/qi/int_parser.cpp). The 41 tests were 42 </p> 43<div class="orderedlist"><ol class="orderedlist" type="1"> 44<li class="listitem"> 45 compiled using gcc-4.6.3 and gcc-4.8.2; 46 </li> 47<li class="listitem"> 48 with optimization: <code class="computeroutput"><span class="identifier">g</span><span class="special">++</span> <span class="special">-</span><span class="identifier">O3</span> 49 <span class="identifier">test</span><span class="special">/</span><span class="identifier">performance_spirit</span><span class="special">.</span><span class="identifier">cpp</span> <span class="special">-</span><span class="identifier">Iinclude</span> <span class="special">-</span><span class="identifier">I</span><span class="special">../</span><span class="identifier">boost_1_56_0</span> <span class="special">-</span><span class="identifier">lrt</span></code>; 50 </li> 51<li class="listitem"> 52 on 64-bit Ubuntu 12.04 and 32-bit Ubuntu 14.04; 53 </li> 54<li class="listitem"> 55 run against the input of randomly generated 18 numeric strings (9 positive 56 and 9 negative numbers with the number of digits from 1 to 9); 57 </li> 58<li class="listitem"> 59 run for 60 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 61<li class="listitem"> 62 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lexical_cast</span></code> and <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lexical_cast</span></code>-based converter; 63 </li> 64<li class="listitem"> 65 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">qi</span><span class="special">::</span><span class="identifier">parse</span></code> and <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">qi</span><span class="special">::</span><span class="identifier">parse</span></code>-based 66 converter. 67 </li> 68</ul></div> 69 </li> 70</ol></div> 71<p> 72 The purpose of the test was to deploy the same functionality directly and 73 as part of the <span class="emphasis"><em>Boost.Convert</em></span> framework. Results are 74 shown below for several consecutive runs: 75 </p> 76<pre class="programlisting"><span class="identifier">gcc</span><span class="special">-</span><span class="number">4.6</span><span class="special">.</span><span class="number">3</span> <span class="special">(</span><span class="number">64</span><span class="special">-</span><span class="identifier">bit</span><span class="special">)</span> 77<span class="identifier">raw_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">1.0504170070</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> 78<span class="identifier">cnv_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">1.0610595810</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">slower</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span> 79<span class="identifier">raw_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">0.2845369110</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> 80<span class="identifier">cnv_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">0.2834834560</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">faster</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span> 81 82<span class="identifier">raw_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">1.0770350390</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">2</span><span class="special">%</span> <span class="identifier">slower</span> <span class="identifier">than</span> <span class="identifier">prev</span><span class="special">.</span> <span class="identifier">run</span><span class="special">)</span> 83<span class="identifier">cnv_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">1.0607665160</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">faster</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span> 84<span class="identifier">raw_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">0.2792295470</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">2</span><span class="special">%</span> <span class="identifier">faster</span> <span class="identifier">than</span> <span class="identifier">prev</span><span class="special">.</span> <span class="identifier">run</span><span class="special">)</span> 85<span class="identifier">cnv_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">0.2827574570</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">slower</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span> 86 87<span class="identifier">gcc</span><span class="special">-</span><span class="number">4.8</span><span class="special">.</span><span class="number">2</span> <span class="special">(</span><span class="number">32</span><span class="special">-</span><span class="identifier">bit</span><span class="special">)</span> 88<span class="identifier">raw_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">8.5153330600</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> 89<span class="identifier">cnv_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">8.6989499850</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">2</span><span class="special">%</span> <span class="identifier">slower</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span> 90<span class="identifier">raw_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">2.4197476510</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> 91<span class="identifier">cnv_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">2.4594171510</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">2</span><span class="special">%</span> <span class="identifier">slower</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span> 92 93<span class="identifier">raw_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">8.4136546980</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">faster</span> <span class="identifier">than</span> <span class="identifier">prev</span><span class="special">.</span> <span class="identifier">run</span><span class="special">)</span> 94<span class="identifier">cnv_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">8.5322524600</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">slower</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span> 95<span class="identifier">raw_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">2.3842388060</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">faster</span> <span class="identifier">than</span> <span class="identifier">prev</span><span class="special">.</span> <span class="identifier">run</span><span class="special">)</span> 96<span class="identifier">cnv_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">2.3812094400</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">0</span><span class="special">%</span> <span class="identifier">faster</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span> 97</pre> 98<p> 99 The results for consecutive runs varied with deviations of around 2%. Under 100 2% was also the deviation of the "cnv" code compared to the "raw" 101 code. That indicates that the <span class="emphasis"><em>Boost.Convert</em></span> framework 102 had no detectable running overhead with the tested compilers, hardware and 103 deployment scenarios. The results might be different on other platforms. 104 </p> 105</div> 106<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 107<td align="left"></td> 108<td align="right"><div class="copyright-footer">Copyright © 2009-2016 Vladimir Batov<p> 109 Distributed under the Boost Software License, Version 1.0. See copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>. 110 </p> 111</div></td> 112</tr></table> 113<hr> 114<div class="spirit-nav"> 115<a accesskey="p" href="../performance.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../performance.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_bigger_picture.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 116</div> 117</body> 118</html> 119