Boost Pool performance comparison

Source: Internet
Author: User

// Testpool. cpp: defines the entry point for the console application <SPAN class = 'wp _ keywordlink '> Program </span>. <Br/> // </P> <p> # include "stdafx. H "<br/> # include <boost/pool/object_pool.hpp> <br/> # include <boost/pool. HPP> </P> <p> using namespace STD; <br/> using namespace boost; </P> <p> class member <br/> {<br/> Public: <br/> byte BC; <br/> int * IA; <br/> INTIB [1, 100]; <br/> Public: <br/> member () <br/>{</P> <p >}< br/>}; <br/> typedef member * pmember; </P> <p> // 2 <br/> object_pool <member> m_pool2; </P> <p> // 1 <br/> pool <> m_pool (sizeof (member )); </P> <p> # define MAX 1000 </P> <p> int _ tmain (INT argc, _ tchar * argv []) <br/>{< br/> DWORD T1 = gettickcount (); <br/> pmember M [Max]; <br/> // 1 <br/> for (INT I = 0; I <Max; I ++) <br/>{< br/> M [I] = (pmember) m_pool.malloc (); <br/>}< br/> for (INT I = 0; I <Max; I ++) <br/>{< br/> m_pool.free (M [I]); <br/>}< br/> printf ("time1 val = % d/N", gettickcount ()-t1 ); // ----------- 0 Ms </P> <p> // 2 <br/> T1 = gettickcount (); <br/> for (INT I = 0; I <Max; I ++) <br/>{< br/> M [I] = (pmember) m_pool2.malloc (); <br/> // M [I] = m_pool2.construct (); <br/>}< br/> for (INT I = 0; I <Max; I ++) <br/>{< br/> m_pool2.free (M [I]); <br/>}< br/> printf ("time2 val = % d/N ", gettickcount ()-t1); // ----------- 60-80 ms </P> <p> system ("pause"); <br/> return 0; <br/>}</P> <p>

 

The memory release of the object_pool is indeed lagging behind. No wonder some people say that the object_pool is a failure in the boost pool.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.