30#include <wx/filename.h>
55 std::cerr <<
"Usage: fill_bench <board.kicad_pcb> [iterations]" << std::endl;
59 wxString boardPath = wxString::FromUTF8( argv[1] );
60 int iterations = argc > 2 ? std::atoi( argv[2] ) : 1;
62 std::unique_ptr<BOARD> board;
67 std::cout <<
"Load: " << loadTimer.
SinceStart<std::chrono::milliseconds>().count() <<
" ms"
73 std::cerr <<
"Failed to load board" << std::endl;
79 auto drcEngine = std::make_shared<DRC_ENGINE>( board.get(), &bds );
80 drcEngine->InitEngine( wxFileName() );
83 board->BuildListOfNets();
84 board->BuildConnectivity();
86 std::cout <<
"Zones: " << board->Zones().size() <<
", nets: " << board->GetNetCount() << std::endl;
89 toolMgr.
SetEnvironment( board.get(),
nullptr,
nullptr,
nullptr,
nullptr );
94 std::vector<ZONE*> toFill;
96 for(
ZONE* zone : board->Zones() )
97 toFill.push_back( zone );
99 for(
int i = 0; i < iterations; ++i )
105 bool ok = filler.
Fill( toFill,
false,
nullptr );
106 double ms =
static_cast<double>( fillTimer.
SinceStart<std::chrono::milliseconds>().count() );
108 std::cout <<
"Fill #" << i <<
": " << ms <<
" ms" << ( ok ?
"" :
" (FAILED)" )
114 unsigned long long outlineCount = 0;
115 unsigned long long vertexCount = 0;
121 for(
ZONE* zone : board->Zones() )
125 if( !zone->HasFilledPolysForLayer( layer ) )
128 std::shared_ptr<SHAPE_POLY_SET> polys = zone->GetFilledPolysList( layer );
130 outlineCount += (
unsigned long long) polys->OutlineCount();
131 vertexCount += (
unsigned long long) polys->FullPointCount();
133 for(
auto it = polys->CIterateWithHoles(); it; ++it )
135 streamHash.
add( it->x );
136 streamHash.
add( it->y );
143 std::cout <<
"FillSummary area=" << std::fixed <<
totalArea <<
" outlines=" << outlineCount
144 <<
" vertices=" << vertexCount <<
" streamhash=" << digest.
ToString() << std::endl;
151 "Benchmark zone filling on a board",
Container for design settings for a BOARD object.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
A streaming C++ equivalent for MurmurHash3_x64_128.
FORCE_INLINE void add(const std::string &input)
FORCE_INLINE HASH_128 digest()
static BOARD * Load(PCB_FILE_T aFileType, const wxString &aFileName, BOARD *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Find the requested #PLUGIN and if found, calls the #PLUGIN::LoadBoard() function on it using the argu...
@ KICAD_SEXP
S-expression Pcbnew file format.
A small class to help profiling.
DURATION SinceStart(bool aSinceLast=false)
static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
bool Fill(const std::vector< ZONE * > &aZones, bool aCheck=false, wxWindow *aParent=nullptr)
Fills the given list of zones.
Handle a list of polygons defining a copper zone.
PCB_LAYER_ID
A quick note on layer IDs:
@ TOOL_SPECIFIC
Tools can define their own statuses from here onwards.
@ BAD_CMDLINE
The command line was not correct for the tool.
A storage class for 128-bit hash value.
std::string ToString() const