Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: Generally, are the programs written by C++ slower than written by C 10% ? Date: Wed, 07 Sep 2011 21:51:19 +1200 Lines: 17 Message-ID: <9cot4nF72aU15@mid.individual.net> References: <9cmc6qF72aU5@mid.individual.net> <08475db4-81c0-4e57-bddd-0c56107b6aed@n19g2000prh.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net KN/44U1287BoCMJ8JXoR1QnwjKmgF+peEoa/pmbPHLUSCrlzS5 Cancel-Lock: sha1:IRpcEExTfzqSybEZ/gFzMYlH79U= User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:9881 On 09/ 7/11 09:45 PM, none Yannick Tremblay wrote: > KaiWen wrote: > >> It is slower than malloc, it's true. Unless reuse it. > > Logically, std::string allocating a buffer is unlikely to be faster > than malloc for allocating memory. However, micro-benchmark tend to > by pretty irrelevant in real programs. They typically concentrate on > one single area while ignoring other potentially much more important > areas. Very true. I have a conversion application that spends nearly all of its run time searching and modifying tens of thousands of strings. Allocation times are way way down the profiler's output. -- Ian Collins