qa/pns: added trivial PCB rendering performance test program

This commit is contained in:
Tomasz Wlostowski 2021-11-28 21:52:42 +01:00
parent 4b243c425b
commit 5f2aaba0dd
3 changed files with 70 additions and 2 deletions

View File

@ -31,6 +31,7 @@
#include <pgm_base.h>
#include <profile.h>
#include <trace_helpers.h>
#include <view/view_overlay.h>
@ -290,7 +291,7 @@ PNS_LOG_VIEWER_FRAME::PNS_LOG_VIEWER_FRAME( wxFrame* frame ) : PNS_LOG_VIEWER_FR
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
m_galPanel->GetView()->GetPainter()->GetSettings() );
settings->SetZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE );
settings->SetZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FILLED );
m_listPopupMenu = new wxMenu( wxT( "" ) );
m_listPopupMenu->Append( ID_LIST_COPY, wxT( "Copy selected geometry" ), wxT( "" ),
@ -481,6 +482,22 @@ void PNS_LOG_VIEWER_FRAME::SetLogFile( PNS_LOG_FILE* aLog )
}
void PNS_LOG_VIEWER_FRAME::SetBoard2( std::shared_ptr<BOARD> aBoard )
{
SetBoard( aBoard );
auto extents = m_board->GetBoundingBox();
BOX2D bbd;
bbd.SetOrigin( extents.GetOrigin() );
bbd.SetWidth( extents.GetWidth() );
bbd.SetHeight( extents.GetHeight() );
bbd.Inflate( std::min( bbd.GetWidth(), bbd.GetHeight() ) / 5 );
m_galPanel->GetView()->SetViewport( bbd );
}
void PNS_LOG_VIEWER_FRAME::onReload( wxCommandEvent& event )
{
event.Skip();
@ -775,3 +792,42 @@ static bool registered2 = UTILITY_REGISTRY::Register( {
"PNS Log Player",
replay_main_func,
} );
int render_perftest_main_func( int argc, char* argv[] )
{
auto frame = new PNS_LOG_VIEWER_FRAME( nullptr );
// drcCreateTestsProviderClearance();
// drcCreateTestsProviderEdgeClearance();
if( argc >= 2 && std::string( argv[1] ) == "-h" )
{
printf( "PCB render performance test. Just renders a board without UI update overhead.\n" );
return 0;
}
if( argc < 2 )
{
printf( "Expected parameters: board_file\n" );
return 0;
}
PROF_COUNTER cnt("load-board");
std::shared_ptr<BOARD> brd ( loadBoard( argv[1] ) );
cnt.Stop();
KI_TRACE( traceGalProfile, "%s\n", cnt.to_string() );
frame->SetBoard2( brd );
return 0;
}
static bool registered3 = UTILITY_REGISTRY::Register( {
"render_perftest",
"Renderer performance test",
render_perftest_main_func,
} );

View File

@ -47,6 +47,8 @@ public:
virtual ~PNS_LOG_VIEWER_FRAME();
void SetLogFile( PNS_LOG_FILE* aLog );
void SetBoard2( std::shared_ptr<BOARD> aBoard );
std::shared_ptr<PNS_LOG_VIEWER_OVERLAY> GetOverlay() const { return m_overlay; }
private:

View File

@ -30,7 +30,7 @@
#include <wx/log.h>
#include <wx/popupwin.h>
#include <wx/cmdline.h>
#include <profile.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
@ -68,6 +68,7 @@
#include "pcb_test_frame.h"
#include <trace_helpers.h>
using namespace KIGFX;
@ -76,10 +77,19 @@ void PCB_TEST_FRAME_BASE::SetBoard( std::shared_ptr<BOARD> b )
{
m_board = b;
PROF_COUNTER cntConnectivity( "connectivity-build" );
m_board->GetConnectivity()->Build( m_board.get() );
cntConnectivity.Stop();
PROF_COUNTER cntView("view-build");
m_galPanel->DisplayBoard( m_board.get() );
cntView.Stop();
m_galPanel->UpdateColors();
KI_TRACE( traceGalProfile, "%s\n", cntConnectivity.to_string() );
KI_TRACE( traceGalProfile, "%s\n", cntView.to_string() );
#ifdef USE_TOOL_MANAGER
m_toolManager->SetEnvironment( m_board.get(), m_galPanel->GetView(),
m_galPanel->GetViewControls(), nullptr );