Use 64-bit type to represent microseconds.
int and long are 32-bit on Windows, causing overflows.
This commit is contained in:
parent
337489c77d
commit
85b1978408
|
@ -530,7 +530,7 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
|
|||
m_boardBoundingBox = BBOX_3D( boardMin, boardMax );
|
||||
|
||||
#ifdef PRINT_STATISTICS_3D_VIEWER
|
||||
unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs();
|
||||
int64_t stats_startCreateBoardPolyTime = GetRunningMicroSecs();
|
||||
#endif
|
||||
|
||||
if( aStatusReporter )
|
||||
|
|
|
@ -155,9 +155,9 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
|
|||
// https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L692
|
||||
|
||||
#ifdef PRINT_STATISTICS_3D_VIEWER
|
||||
unsigned stats_startCopperLayersTime = GetRunningMicroSecs();
|
||||
int64_t stats_startCopperLayersTime = GetRunningMicroSecs();
|
||||
|
||||
unsigned start_Time = stats_startCopperLayersTime;
|
||||
int64_t start_Time = stats_startCopperLayersTime;
|
||||
#endif
|
||||
|
||||
PCB_LAYER_ID cu_seq[MAX_CU_LAYERS];
|
||||
|
|
|
@ -369,7 +369,7 @@ void EDA_3D_CANVAS::DoRePaint()
|
|||
wxString err_messages;
|
||||
INFOBAR_REPORTER warningReporter( m_parentInfoBar );
|
||||
STATUSBAR_REPORTER activityReporter( m_parentStatusBar, EDA_3D_VIEWER_STATUSBAR::ACTIVITY );
|
||||
unsigned start_time = GetRunningMicroSecs();
|
||||
int64_t start_time = GetRunningMicroSecs();
|
||||
|
||||
// "Makes the OpenGL state that is represented by the OpenGL rendering
|
||||
// context context current, i.e. it will be used by all subsequent OpenGL calls.
|
||||
|
@ -461,7 +461,7 @@ void EDA_3D_CANVAS::DoRePaint()
|
|||
|
||||
if( m_camera_is_moving )
|
||||
{
|
||||
const unsigned curtime_delta = GetRunningMicroSecs() - m_strtime_camera_movement;
|
||||
const int64_t curtime_delta = GetRunningMicroSecs() - m_strtime_camera_movement;
|
||||
curtime_delta_s = (curtime_delta / 1e6) * m_camera_moving_speed;
|
||||
m_camera.Interpolate( curtime_delta_s );
|
||||
|
||||
|
|
|
@ -305,7 +305,7 @@ private:
|
|||
|
||||
bool m_render_pivot; // Render the pivot while camera moving
|
||||
float m_camera_moving_speed; // 1.0f will be 1:1
|
||||
unsigned m_strtime_camera_movement; // Ticktime of camera movement start
|
||||
int64_t m_strtime_camera_movement; // Ticktime of camera movement start
|
||||
bool m_animation_enabled; // Camera animation enabled
|
||||
int m_moving_speed_multiplier; // Camera animation speed multiplier option
|
||||
|
||||
|
|
|
@ -454,7 +454,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
|
|||
|
||||
OBJECT_2D_STATS::Instance().ResetStats();
|
||||
|
||||
unsigned stats_startReloadTime = GetRunningMicroSecs();
|
||||
int64_t stats_startReloadTime = GetRunningMicroSecs();
|
||||
|
||||
m_boardAdapter.InitSettings( aStatusReporter, aWarningReporter );
|
||||
|
||||
|
|
|
@ -368,7 +368,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
|
|||
OBJECT_2D_STATS::Instance().ResetStats();
|
||||
OBJECT_3D_STATS::Instance().ResetStats();
|
||||
|
||||
unsigned stats_startReloadTime = GetRunningMicroSecs();
|
||||
int64_t stats_startReloadTime = GetRunningMicroSecs();
|
||||
|
||||
if( !aOnlyLoadCopperAndShapes )
|
||||
{
|
||||
|
@ -771,8 +771,8 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
|
|||
}
|
||||
|
||||
#ifdef PRINT_STATISTICS_3D_VIEWER
|
||||
unsigned stats_endConvertTime = GetRunningMicroSecs();
|
||||
unsigned stats_startLoad3DmodelsTime = stats_endConvertTime;
|
||||
int64_t stats_endConvertTime = GetRunningMicroSecs();
|
||||
int64_t stats_startLoad3DmodelsTime = stats_endConvertTime;
|
||||
#endif
|
||||
|
||||
if( aStatusReporter )
|
||||
|
@ -781,7 +781,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
|
|||
load3DModels( m_objectContainer, aOnlyLoadCopperAndShapes );
|
||||
|
||||
#ifdef PRINT_STATISTICS_3D_VIEWER
|
||||
unsigned stats_endLoad3DmodelsTime = GetRunningMicroSecs();
|
||||
int64_t stats_endLoad3DmodelsTime = GetRunningMicroSecs();
|
||||
#endif
|
||||
|
||||
if( !aOnlyLoadCopperAndShapes )
|
||||
|
@ -955,7 +955,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
|
|||
if( aStatusReporter )
|
||||
{
|
||||
// Calculation time in seconds
|
||||
double calculation_time = (double) GetRunningMicroSecs() - stats_startReloadTime / 1e6;
|
||||
double calculation_time = (double) ( GetRunningMicroSecs() - stats_startReloadTime ) / 1e6;
|
||||
|
||||
aStatusReporter->Report( wxString::Format( _( "Reload time %.3f s" ), calculation_time ) );
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ private:
|
|||
RT_RENDER_STATE m_renderState;
|
||||
|
||||
/// Time that the render starts
|
||||
unsigned long int m_renderStartTime;
|
||||
int64_t m_renderStartTime;
|
||||
|
||||
/// Save the number of blocks progress of the render
|
||||
size_t m_blockRenderProgressCount;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* A small class to help profiling.
|
||||
|
@ -216,7 +217,7 @@ private:
|
|||
* differences between two calls.
|
||||
* @author Dick Hollenbeck
|
||||
*/
|
||||
unsigned GetRunningMicroSecs();
|
||||
int64_t GetRunningMicroSecs();
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,34 +24,35 @@
|
|||
|
||||
|
||||
#include <config.h>
|
||||
#include <cstdint>
|
||||
|
||||
#if defined( _WIN32 )
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <windows.h>
|
||||
|
||||
unsigned GetRunningMicroSecs()
|
||||
int64_t GetRunningMicroSecs()
|
||||
{
|
||||
FILETIME now;
|
||||
|
||||
GetSystemTimeAsFileTime( &now );
|
||||
unsigned long long t = ( UINT64( now.dwHighDateTime ) << 32 ) + now.dwLowDateTime;
|
||||
uint64_t t = ( UINT64( now.dwHighDateTime ) << 32 ) + now.dwLowDateTime;
|
||||
t /= 10;
|
||||
|
||||
return unsigned( t );
|
||||
return int64_t( t );
|
||||
}
|
||||
|
||||
#elif defined( HAVE_CLOCK_GETTIME )
|
||||
|
||||
#include <ctime>
|
||||
|
||||
unsigned GetRunningMicroSecs()
|
||||
int64_t GetRunningMicroSecs()
|
||||
{
|
||||
struct timespec now;
|
||||
|
||||
clock_gettime( CLOCK_MONOTONIC, &now );
|
||||
|
||||
unsigned usecs = ( (unsigned) now.tv_nsec ) / 1000 + ( (unsigned) now.tv_sec ) * 1000000;
|
||||
int64_t usecs = (int64_t) now.tv_sec * 1000000 + now.tv_nsec / 1000;
|
||||
// unsigned msecs = (now.tv_nsec / (1000*1000)) + now.tv_sec * 1000;
|
||||
|
||||
return usecs;
|
||||
|
@ -61,13 +62,13 @@ unsigned GetRunningMicroSecs()
|
|||
#elif defined( HAVE_GETTIMEOFDAY_FUNC )
|
||||
|
||||
#include <sys/time.h>
|
||||
unsigned GetRunningMicroSecs()
|
||||
int64_t GetRunningMicroSecs()
|
||||
{
|
||||
timeval tv;
|
||||
|
||||
gettimeofday( &tv, 0 );
|
||||
|
||||
return ( tv.tv_sec * 1000000 ) + tv.tv_usec;
|
||||
return (int64_t) tv.tv_sec * 1000000 + tv.tv_usec;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -493,7 +493,7 @@ void EXPORTER_STEP::calculatePcbThickness()
|
|||
bool EXPORTER_STEP::Export()
|
||||
{
|
||||
// Display the export time, for statistics
|
||||
unsigned stats_startExportTime = GetRunningMicroSecs();
|
||||
int64_t stats_startExportTime = GetRunningMicroSecs();
|
||||
|
||||
// setup opencascade message log
|
||||
Message::DefaultMessenger()->RemovePrinters( STANDARD_TYPE( Message_PrinterOStream ) );
|
||||
|
|
|
@ -678,14 +678,14 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
|
||||
#if USE_INSTRUMENTATION
|
||||
// measure the time to load a BOARD.
|
||||
unsigned startTime = GetRunningMicroSecs();
|
||||
int64_t startTime = GetRunningMicroSecs();
|
||||
#endif
|
||||
|
||||
pi->SetProgressReporter( &progressReporter );
|
||||
loadedBoard = pi->LoadBoard( fullFileName, nullptr, &props, &Prj() );
|
||||
|
||||
#if USE_INSTRUMENTATION
|
||||
unsigned stopTime = GetRunningMicroSecs();
|
||||
int64_t stopTime = GetRunningMicroSecs();
|
||||
printf( "PCB_IO::Load(): %u usecs\n", stopTime - startTime );
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ int ZONE_FILLER_TOOL::ZoneFillDirty( const TOOL_EVENT& aEvent )
|
|||
if( m_fillInProgress )
|
||||
return 0;
|
||||
|
||||
unsigned startTime = GetRunningMicroSecs();
|
||||
int64_t startTime = GetRunningMicroSecs();
|
||||
m_fillInProgress = true;
|
||||
|
||||
m_dirtyZoneIDs.clear();
|
||||
|
|
Loading…
Reference in New Issue