Performance counter rework: More comments, code cleaning, and move GetRunningMicroSecs() prototype from common.h to profile.h.
profile.h should now contain all info for profiling.
This commit is contained in:
parent
fff449ecf0
commit
d56a49d218
|
@ -42,7 +42,6 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "3d_cache.h"
|
#include "3d_cache.h"
|
||||||
#include "3d_info.h"
|
#include "3d_info.h"
|
||||||
#include "common.h"
|
|
||||||
#include "sg/scenegraph.h"
|
#include "sg/scenegraph.h"
|
||||||
#include "3d_filename_resolver.h"
|
#include "3d_filename_resolver.h"
|
||||||
#include "3d_plugin_manager.h"
|
#include "3d_plugin_manager.h"
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include "status_text_reporter.h"
|
#include "status_text_reporter.h"
|
||||||
#include <gl_context_mgr.h>
|
#include <gl_context_mgr.h>
|
||||||
|
#include <profile.h> // To use GetRunningMicroSecs or an other profiling utility
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trace mask used to enable or disable the trace output of this class.
|
* Trace mask used to enable or disable the trace output of this class.
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "../../3d_fastmath.h"
|
#include "../../3d_fastmath.h"
|
||||||
#include <trigo.h>
|
#include <trigo.h>
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
|
#include <profile.h> // To use GetRunningMicroSecs or an other profiling utility
|
||||||
|
|
||||||
|
|
||||||
void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CFILLEDCIRCLE2D * aFilledCircle,
|
void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CFILLEDCIRCLE2D * aFilledCircle,
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include <class_module.h>
|
#include <class_module.h>
|
||||||
|
|
||||||
#include <base_units.h>
|
#include <base_units.h>
|
||||||
|
#include <profile.h> // To use GetRunningMicroSecs or an other profiling utility
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scale convertion from 3d model units to pcb units
|
* Scale convertion from 3d model units to pcb units
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "3d_fastmath.h"
|
#include "3d_fastmath.h"
|
||||||
#include "3d_math.h"
|
#include "3d_math.h"
|
||||||
#include "../common_ogl/ogl_utils.h"
|
#include "../common_ogl/ogl_utils.h"
|
||||||
|
#include <profile.h> // To use GetRunningMicroSecs or an other profiling utility
|
||||||
|
|
||||||
// This should be used in future for the function
|
// This should be used in future for the function
|
||||||
// convertLinearToSRGB
|
// convertLinearToSRGB
|
||||||
|
|
|
@ -307,7 +307,7 @@ void OPENGL_GAL::BeginDrawing()
|
||||||
compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING );
|
compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING );
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
totalRealTime.stop();
|
totalRealTime.Stop();
|
||||||
wxLogTrace( "GAL_PROFILE",
|
wxLogTrace( "GAL_PROFILE",
|
||||||
wxT( "OPENGL_GAL::BeginDrawing(): %.1f ms" ), totalRealTime.msecs() );
|
wxT( "OPENGL_GAL::BeginDrawing(): %.1f ms" ), totalRealTime.msecs() );
|
||||||
#endif /* __WXDEBUG__ */
|
#endif /* __WXDEBUG__ */
|
||||||
|
@ -341,7 +341,7 @@ void OPENGL_GAL::EndDrawing()
|
||||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( glPrivContext );
|
GL_CONTEXT_MANAGER::Get().UnlockCtx( glPrivContext );
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
totalRealTime.stop();
|
totalRealTime.Stop();
|
||||||
wxLogTrace( "GAL_PROFILE", wxT( "OPENGL_GAL::EndDrawing(): %.1f ms" ), totalRealTime.msecs() );
|
wxLogTrace( "GAL_PROFILE", wxT( "OPENGL_GAL::EndDrawing(): %.1f ms" ), totalRealTime.msecs() );
|
||||||
#endif /* __WXDEBUG__ */
|
#endif /* __WXDEBUG__ */
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,23 +43,6 @@ unsigned GetRunningMicroSecs()
|
||||||
return unsigned( t );
|
return unsigned( t );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
// test program
|
|
||||||
#include <stdio.h>
|
|
||||||
int main( int argc, char** argv )
|
|
||||||
{
|
|
||||||
unsigned then = GetRunningMicroSecs();
|
|
||||||
|
|
||||||
Sleep( 2000 ); // Windows Sleep( msecs )
|
|
||||||
|
|
||||||
printf( "delta: %u\n", GetRunningMicroSecs() - then );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined(HAVE_CLOCK_GETTIME)
|
#elif defined(HAVE_CLOCK_GETTIME)
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2014-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2007-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2007-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
||||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -304,14 +304,6 @@ double RoundTo0( double x, double precision );
|
||||||
*/
|
*/
|
||||||
void wxStringSplit( const wxString& aText, wxArrayString& aStrings, wxChar aSplitter );
|
void wxStringSplit( const wxString& aText, wxArrayString& aStrings, wxChar aSplitter );
|
||||||
|
|
||||||
/**
|
|
||||||
* Function GetRunningMicroSecs
|
|
||||||
* returns an ever increasing indication of elapsed microseconds. Use this
|
|
||||||
* by computing differences between two calls.
|
|
||||||
* @author Dick Hollenbeck
|
|
||||||
*/
|
|
||||||
unsigned GetRunningMicroSecs();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SystemDirsAppend
|
* Function SystemDirsAppend
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 CERN
|
* Copyright (C) 2013 CERN
|
||||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||||
* 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
* 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -36,6 +36,11 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class PROF_COUNTER is a small class to help profiling.
|
||||||
|
* It allows the calculation of the elapsed time (in millisecondes) between
|
||||||
|
* its creation (or the last call to Start() ) and the last call to Stop()
|
||||||
|
*/
|
||||||
class PROF_COUNTER
|
class PROF_COUNTER
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -53,22 +58,26 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a PROF_COUNTER for measuring an elapsed time in milliseconds
|
* Creates a PROF_COUNTER for measuring an elapsed time in milliseconds
|
||||||
* The string that will be printed in message is left empty.
|
* The counter is started and the string to print in message is left empty.
|
||||||
* @param aAutostart = true (default) to immediately start the timer
|
|
||||||
*/
|
*/
|
||||||
PROF_COUNTER( bool aAutostart = true ) :
|
PROF_COUNTER()
|
||||||
m_running( false )
|
|
||||||
{
|
{
|
||||||
if( aAutostart )
|
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts or restarts the counter
|
||||||
|
*/
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
m_running = true;
|
m_running = true;
|
||||||
m_starttime = std::chrono::system_clock::now();
|
m_starttime = std::chrono::system_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save the time when this function was called, and set the counter stane to stop
|
||||||
|
*/
|
||||||
void Stop()
|
void Stop()
|
||||||
{
|
{
|
||||||
if( !m_running )
|
if( !m_running )
|
||||||
|
@ -82,15 +91,12 @@ public:
|
||||||
*/
|
*/
|
||||||
void Show()
|
void Show()
|
||||||
{
|
{
|
||||||
TIME_POINT display_stoptime;
|
TIME_POINT display_stoptime = m_running ?
|
||||||
|
std::chrono::system_clock::now() :
|
||||||
|
m_stoptime;
|
||||||
|
|
||||||
if( m_running )
|
std::chrono::duration<double, std::milli> elapsed = display_stoptime - m_starttime;
|
||||||
display_stoptime = std::chrono::system_clock::now();
|
std::cerr << m_name << " took " << elapsed.count() << " milliseconds." << std::endl;
|
||||||
else
|
|
||||||
display_stoptime = m_stoptime;
|
|
||||||
|
|
||||||
std::chrono::duration<double, std::milli> d = display_stoptime - m_starttime;
|
|
||||||
std::cerr << m_name << " took " << std::setprecision(1) << d.count() << "milliseconds." << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,8 +104,13 @@ public:
|
||||||
*/
|
*/
|
||||||
double msecs() const
|
double msecs() const
|
||||||
{
|
{
|
||||||
std::chrono::duration<double, std::milli> d = m_stoptime - m_starttime;
|
TIME_POINT stoptime = m_running ?
|
||||||
return d.count();
|
std::chrono::system_clock::now() :
|
||||||
|
m_stoptime;
|
||||||
|
|
||||||
|
std::chrono::duration<double, std::milli> elapsed = stoptime - m_starttime;
|
||||||
|
|
||||||
|
return elapsed.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -112,4 +123,13 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetRunningMicroSecs
|
||||||
|
* An alternate way to calculate an elapset time (in microsecondes) to class PROF_COUNTER
|
||||||
|
* @return an ever increasing indication of elapsed microseconds.
|
||||||
|
* Use this by computing differences between two calls.
|
||||||
|
* @author Dick Hollenbeck
|
||||||
|
*/
|
||||||
|
unsigned GetRunningMicroSecs();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue