Fix compile
This commit is contained in:
@@ -368,8 +368,9 @@ bool DIALOG_PRINT::TransferDataFromWindow()
|
||||
// Using custom page size avoids the problematic
|
||||
// gtk_page_setup_set_paper_size_and_default_margins call in wxWidgets.
|
||||
|
||||
wxPaperSize paperId = data.GetPaperId();
|
||||
const wxChar* paperType = nullptr;
|
||||
wxPaperSize paperId = data.GetPaperId();
|
||||
PAGE_SIZE_TYPE paperType = PAGE_SIZE_TYPE::A4; // default; overwritten below when matched
|
||||
bool havePaperType = false;
|
||||
|
||||
// clang-format off
|
||||
std::set<wxPaperSize> letterSizes = {
|
||||
@@ -396,13 +397,22 @@ bool DIALOG_PRINT::TransferDataFromWindow()
|
||||
// clang-format on
|
||||
|
||||
if( letterSizes.count( paperId ) )
|
||||
paperType = PAGE_INFO::USLetter;
|
||||
{
|
||||
paperType = PAGE_SIZE_TYPE::USLetter;
|
||||
havePaperType = true;
|
||||
}
|
||||
else if( legalSizes.count( paperId ) )
|
||||
paperType = PAGE_INFO::USLegal;
|
||||
{
|
||||
paperType = PAGE_SIZE_TYPE::USLegal;
|
||||
havePaperType = true;
|
||||
}
|
||||
else if( a4Sizes.count( paperId ) )
|
||||
paperType = PAGE_INFO::A4;
|
||||
{
|
||||
paperType = PAGE_SIZE_TYPE::A4;
|
||||
havePaperType = true;
|
||||
}
|
||||
|
||||
if( paperType )
|
||||
if( havePaperType )
|
||||
{
|
||||
PAGE_INFO pageInfo( paperType, data.GetOrientation() == wxPORTRAIT );
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Symbol chooser timing instrumentation.
|
||||
*
|
||||
* Enable with environment variable:
|
||||
* KICAD_TRACE=KI_TRACE_SYM_CHOOSER
|
||||
*
|
||||
* Logs lines of the form:
|
||||
* KI_TRACE_SYM_CHOOSER | step=<name> step_ms=XX.XXX total_ms=YY.YYY mode=cold|warm [extra]
|
||||
*
|
||||
* "cold" = first symbol chooser session (initial library load)
|
||||
* "warm" = subsequent sessions (should mostly hit caches)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <wx/string.h>
|
||||
#include <trace_helpers.h>
|
||||
|
||||
namespace SYM_CHOOSER_TIMING
|
||||
{
|
||||
using clock = std::chrono::steady_clock;
|
||||
using ms = std::chrono::duration<double, std::milli>;
|
||||
|
||||
inline clock::time_point g_start_time; // Set at beginning of PickSymbolFromLibrary
|
||||
inline bool g_started = false;
|
||||
inline bool g_firstRun = true; // Cleared after first full AddLibraries call
|
||||
|
||||
inline void Start()
|
||||
{
|
||||
g_start_time = clock::now();
|
||||
g_started = true;
|
||||
}
|
||||
|
||||
inline double TotalMs()
|
||||
{
|
||||
if( !g_started )
|
||||
return 0.0;
|
||||
return ms( clock::now() - g_start_time ).count();
|
||||
}
|
||||
|
||||
// Helper object to measure and log incremental steps relative to g_start_time
|
||||
class STEP_LOGGER
|
||||
{
|
||||
public:
|
||||
STEP_LOGGER()
|
||||
{
|
||||
m_last = g_started ? g_start_time : clock::now();
|
||||
}
|
||||
|
||||
void Log( const char* aStep, const wxString& aExtra = wxEmptyString )
|
||||
{
|
||||
auto now = clock::now();
|
||||
double step_ms = ms( now - m_last ).count();
|
||||
double total_ms = g_started ? ms( now - g_start_time ).count() : step_ms;
|
||||
m_last = now;
|
||||
|
||||
KI_TRACE( wxT("KI_TRACE_SYM_CHOOSER"), wxT("step=%s step_ms=%.3f total_ms=%.3f mode=%s%s%s\n"),
|
||||
wxString::FromUTF8( aStep ).c_str(), step_ms, total_ms,
|
||||
g_firstRun ? wxT("cold") : wxT("warm"),
|
||||
aExtra.IsEmpty() ? wxT("") : wxT(" "),
|
||||
aExtra.c_str() );
|
||||
}
|
||||
|
||||
private:
|
||||
clock::time_point m_last;
|
||||
};
|
||||
|
||||
inline void LogRaw( const char* aStep, double aStepMs, double aTotalMs, const wxString& aExtra = wxEmptyString )
|
||||
{
|
||||
KI_TRACE( wxT("KI_TRACE_SYM_CHOOSER"), wxT("step=%s step_ms=%.3f total_ms=%.3f mode=%s%s%s\n"),
|
||||
wxString::FromUTF8( aStep ).c_str(), aStepMs, aTotalMs,
|
||||
g_firstRun ? wxT("cold") : wxT("warm"),
|
||||
aExtra.IsEmpty() ? wxT("") : wxT(" "),
|
||||
aExtra.c_str() );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user