Commit 00052a60 authored by Dick Hollenbeck's avatar Dick Hollenbeck

add container_test

parent 9d080b08
2012-Jan-5 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++all
Ki_PageDescr was re-written as a proper C++ class and renamed to PAGE_INFO.
It describes paper. The m_Offset field was dropped since it was only used
in HPGL plotting within EESCHEMA. PAGE_INFO instance was moved out of
BASE_SCREEN (which is on its way out) into both SCH_SCREEN and BOARD.
KiCad ChangeLog 2011
====================
Please add newer entries at the top, list the date and your name with
email address.
2011-Dec-19, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
Pcbnew:
......
#include <base_struct.h>
#include <boost/ptr_container/ptr_vector.hpp>
#include <deque>
#include <dlist.h>
#include <time.h>
#define TEST_NODES 100000000
//typedef std::vector<EDA_ITEM*> EDA_ITEMV;
//typedef std::deque<EDA_ITEM*> EDA_ITEMV;
typedef boost::ptr_vector<EDA_ITEM> EDA_ITEMV;
void heap_warm_up();
/**
* Function GetRunningMicroSecs
* returns current relative time in microsecs.
*/
unsigned GetRunningMicroSecs()
{
struct timespec now;
clock_gettime( CLOCK_MONOTONIC, &now );
unsigned usecs = now.tv_nsec/1000 + now.tv_sec * 1000 * 1000;
return usecs;
}
int main( int argc, char** argv )
{
EDA_ITEMV v;
DLIST<EDA_ITEM> dlist;
unsigned vAllocStart;
unsigned vAllocStop;
unsigned vIterateStart;
unsigned vIterateStop;
unsigned dAllocStart;
unsigned dAllocStop;
unsigned dIterateStart;
unsigned dIterateStop;
heap_warm_up();
vAllocStart = GetRunningMicroSecs();
for( int i=0; i<TEST_NODES; ++i )
{
v.push_back( new EDA_ITEM( NOT_USED ) );
}
vAllocStop = GetRunningMicroSecs();
vIterateStart = vAllocStop;
for( EDA_ITEMV::const_iterator it = v.begin(); it != v.end(); ++it )
{
if( it->Type() == -22 )
{
printf( "never this\n" );
break;
}
}
vIterateStop = GetRunningMicroSecs();
#if 0
for( int i=0; i<TEST_NODES; ++i )
{
delete v[i];
}
#endif
v.clear();
dAllocStart = GetRunningMicroSecs();
for( int i=0; i<TEST_NODES; ++i )
{
dlist.PushBack( new EDA_ITEM( NOT_USED ) );
}
dAllocStop = GetRunningMicroSecs();
dIterateStart = dAllocStop;
for( const EDA_ITEM* it = dlist; it; it = it->Next() )
{
if( it->Type() == -22 )
{
printf( "never this\n" );
break;
}
}
dIterateStop = GetRunningMicroSecs();
printf( "vector alloc: %u usecs iterate: %u usecs\n",
vAllocStop - vAllocStart,
vIterateStop - vIterateStart );
printf( "dlist alloc: %u usecs iterate: %u usecs\n",
dAllocStop - dAllocStart,
dIterateStop - dIterateStart );
}
void heap_warm_up()
{
// dry run allocate enough object for process to obtain all memory needed
EDA_ITEMV vec;
for( int i=0; i<TEST_NODES; ++i )
{
vec.push_back( new EDA_ITEM( NOT_USED ) );
}
for( int i=0; i<TEST_NODES; ++i )
{
// delete vec[i];
}
vec.clear();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment