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