add GetRunningMicroSecs() to libcommon for debug timing
This commit is contained in:
parent
f40a92561c
commit
3421863c01
|
@ -39,6 +39,9 @@
|
||||||
macro(perform_feature_checks)
|
macro(perform_feature_checks)
|
||||||
|
|
||||||
include(CheckIncludeFile)
|
include(CheckIncludeFile)
|
||||||
|
#include(CheckFunctionExists)
|
||||||
|
include(CheckLibraryExists)
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
|
||||||
check_include_file("malloc.h" HAVE_MALLOC_H)
|
check_include_file("malloc.h" HAVE_MALLOC_H)
|
||||||
|
|
||||||
|
@ -55,7 +58,6 @@ macro(perform_feature_checks)
|
||||||
# re-introduce this.
|
# re-introduce this.
|
||||||
# check_include_file("strings.h" HAVE_STRINGS_H)
|
# check_include_file("strings.h" HAVE_STRINGS_H)
|
||||||
|
|
||||||
include(CheckSymbolExists)
|
|
||||||
check_symbol_exists(strcasecmp "string.h" HAVE_STRCASECMP)
|
check_symbol_exists(strcasecmp "string.h" HAVE_STRCASECMP)
|
||||||
check_symbol_exists(strcasecmp "strings.h" HAVE_STRCASECMP)
|
check_symbol_exists(strcasecmp "strings.h" HAVE_STRCASECMP)
|
||||||
check_symbol_exists(strncasecmp "string.h" HAVE_STRNCASECMP)
|
check_symbol_exists(strncasecmp "string.h" HAVE_STRNCASECMP)
|
||||||
|
@ -70,6 +72,12 @@ macro(perform_feature_checks)
|
||||||
check_symbol_exists(_snprintf "stdio.h" HAVE_ISO_SNPRINTF)
|
check_symbol_exists(_snprintf "stdio.h" HAVE_ISO_SNPRINTF)
|
||||||
check_symbol_exists(_hypot "math.h" HAVE_ISO_HYPOT)
|
check_symbol_exists(_hypot "math.h" HAVE_ISO_HYPOT)
|
||||||
|
|
||||||
|
#check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME) non-standard library, does not work
|
||||||
|
check_library_exists(rt clock_gettime "" HAVE_CLOCK_GETTIME)
|
||||||
|
|
||||||
|
# HAVE_GETTIMEOFDAY is already in use within 2.9 wxWidgets, so use HAVE_GETTIMEOFDAY_FUNC
|
||||||
|
check_symbol_exists(gettimeofday "sys/time.h" HAVE_GETTIMEOFDAY_FUNC)
|
||||||
|
|
||||||
# Generate config.h.
|
# Generate config.h.
|
||||||
configure_file(${PROJECT_SOURCE_DIR}/CMakeModules/config.h.cmake
|
configure_file(${PROJECT_SOURCE_DIR}/CMakeModules/config.h.cmake
|
||||||
${CMAKE_BINARY_DIR}/config.h)
|
${CMAKE_BINARY_DIR}/config.h)
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
#define hypot _hypot
|
#define hypot _hypot
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#cmakedefine HAVE_CLOCK_GETTIME
|
||||||
|
#cmakedefine HAVE_GETTIMEOFDAY_FUNC
|
||||||
|
|
||||||
#cmakedefine MALLOC_IN_STDLIB_H
|
#cmakedefine MALLOC_IN_STDLIB_H
|
||||||
|
|
||||||
#if !defined( MALLOC_IN_STDLIB_H )
|
#if !defined( MALLOC_IN_STDLIB_H )
|
||||||
|
|
|
@ -54,6 +54,7 @@ set(COMMON_SRCS
|
||||||
eda_doc.cpp
|
eda_doc.cpp
|
||||||
filter_reader.cpp
|
filter_reader.cpp
|
||||||
gestfich.cpp
|
gestfich.cpp
|
||||||
|
getrunningmicrosecs.cpp
|
||||||
gr_basic.cpp
|
gr_basic.cpp
|
||||||
hotkeys_basic.cpp
|
hotkeys_basic.cpp
|
||||||
hotkey_grid_table.cpp
|
hotkey_grid_table.cpp
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(HAVE_CLOCK_GETTIME)
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
unsigned GetRunningMicroSecs()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
|
||||||
|
clock_gettime( CLOCK_MONOTONIC, &now );
|
||||||
|
|
||||||
|
unsigned usecs = ((unsigned)now.tv_nsec)/1000 + ((unsigned)now.tv_sec) * 1000000;
|
||||||
|
// unsigned msecs = (now.tv_nsec / (1000*1000)) + now.tv_sec * 1000;
|
||||||
|
|
||||||
|
return usecs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined(HAVE_GETTIMEOFDAY_FUNC)
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
unsigned GetRunningMicroSecs()
|
||||||
|
{
|
||||||
|
timeval tv;
|
||||||
|
|
||||||
|
gettimeofday( &tv, 0 );
|
||||||
|
|
||||||
|
return (tv.tv_sec * 1000000) + tv.tv_usec;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
|
#include <windows.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
unsigned GetRunningMicroSecs()
|
||||||
|
{
|
||||||
|
LARGE_INTEGER curtime;
|
||||||
|
|
||||||
|
static unsigned timerFreq; // timer frequency
|
||||||
|
|
||||||
|
if( !timerFreq )
|
||||||
|
{
|
||||||
|
QueryPerformanceFrequency( &curtime );
|
||||||
|
|
||||||
|
timerFreq = curtime.QuadPart / 1000000; // i.e., ticks per usec
|
||||||
|
|
||||||
|
assert( timerFreq );
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryPerformanceCounter( &curtime );
|
||||||
|
|
||||||
|
return ( curtime.LowPart / timerFreq );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <dlist.h>
|
#include <dlist.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
#define TEST_NODES 100000000
|
#define TEST_NODES 100000000
|
||||||
|
|
||||||
|
@ -16,22 +16,6 @@ typedef boost::ptr_vector<EDA_ITEM> EDA_ITEMV;
|
||||||
|
|
||||||
void heap_warm_up();
|
void heap_warm_up();
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function GetRunningMicroSecs
|
|
||||||
* returns current relative time in microsecs.
|
|
||||||
*/
|
|
||||||
unsigned GetRunningMicroSecs()
|
|
||||||
{
|
|
||||||
struct timespec now;
|
|
||||||
|
|
||||||
clock_gettime( CLOCK_MONOTONIC, &now );
|
|
||||||
|
|
||||||
unsigned usecs = now.tv_nsec/1000 + now.tv_sec * 1000 * 1000;
|
|
||||||
return usecs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
EDA_ITEMV v;
|
EDA_ITEMV v;
|
||||||
|
|
|
@ -506,4 +506,12 @@ int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value );
|
||||||
*/
|
*/
|
||||||
wxString GenDate();
|
wxString GenDate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetRunningMicroSecs
|
||||||
|
* returns an ever increasing indication of elapsed microseconds. Use this
|
||||||
|
* by computing differences between two calls.
|
||||||
|
* @author Dick Hollenbeck
|
||||||
|
*/
|
||||||
|
unsigned GetRunningMicroSecs();
|
||||||
|
|
||||||
#endif // INCLUDE__COMMON_H_
|
#endif // INCLUDE__COMMON_H_
|
||||||
|
|
|
@ -60,7 +60,6 @@
|
||||||
#include <auto_ptr.h>
|
#include <auto_ptr.h>
|
||||||
#include <kicad_string.h>
|
#include <kicad_string.h>
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
//#include <build_version.h>
|
|
||||||
#include <zones.h>
|
#include <zones.h>
|
||||||
|
|
||||||
#ifdef CVPCB
|
#ifdef CVPCB
|
||||||
|
@ -256,13 +255,11 @@ void KICAD_PLUGIN::loadAllSections( bool doAppend )
|
||||||
loadPCB_TARGET();
|
loadPCB_TARGET();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PCBNEW)
|
|
||||||
else if( TESTLINE( "$ZONE" ) )
|
else if( TESTLINE( "$ZONE" ) )
|
||||||
{
|
{
|
||||||
SEGZONE* insertBeforeMe = doAppend ? NULL : m_board->m_Zone.GetFirst();
|
SEGZONE* insertBeforeMe = doAppend ? NULL : m_board->m_Zone.GetFirst();
|
||||||
loadTrackList( insertBeforeMe, PCB_ZONE_T );
|
loadTrackList( insertBeforeMe, PCB_ZONE_T );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
else if( TESTLINE( "$GENERAL" ) )
|
else if( TESTLINE( "$GENERAL" ) )
|
||||||
{
|
{
|
||||||
|
@ -568,8 +565,6 @@ void KICAD_PLUGIN::loadSETUP()
|
||||||
m_board->SetOriginAxisPosition( wxPoint( gx, gy ) );
|
m_board->SetOriginAxisPosition( wxPoint( gx, gy ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1 // defined(PCBNEW)
|
|
||||||
|
|
||||||
else if( TESTLINE( "Layers" ) )
|
else if( TESTLINE( "Layers" ) )
|
||||||
{
|
{
|
||||||
int tmp = intParse( line + SZ( "Layers" ) );
|
int tmp = intParse( line + SZ( "Layers" ) );
|
||||||
|
@ -786,7 +781,6 @@ void KICAD_PLUGIN::loadSETUP()
|
||||||
GetScreen()->m_GridOrigin.y = Oy;
|
GetScreen()->m_GridOrigin.y = Oy;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
else if( TESTLINE( "$EndSETUP" ) )
|
else if( TESTLINE( "$EndSETUP" ) )
|
||||||
{
|
{
|
||||||
|
@ -2846,9 +2840,7 @@ void KICAD_PLUGIN::saveSETUP() const
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* @todo no aFrame in a plugin
|
fprintf( m_fp, "AuxiliaryAxisOrg %s\n", fmtBIUPoint( m_board->GetOriginAxisPosition() ).c_str() );
|
||||||
fprintf( m_fp, "AuxiliaryAxisOrg %s\n", fmtBIUPoint( aFrame->GetOriginAxisPosition() ).c_str() );
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* @todo no globals
|
/* @todo no globals
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue