1
0
Fork 0

Optional profiling commands using gperftools

This commit is contained in:
Thomas Geymayer 2012-11-15 11:55:25 +01:00
parent b88e941ca2
commit fe1222a90d
3 changed files with 58 additions and 2 deletions

View file

@ -223,6 +223,9 @@ check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(windows.h HAVE_WINDOWS_H)
# check optionally supported dependencies
find_package(GooglePerfTools)
if(ENABLE_RTI)
find_package(RTI)
if(RTI_FOUND)

View file

@ -90,6 +90,10 @@ if(ENABLE_JSBSIM)
target_link_libraries(fgfs JSBSim)
endif()
if(GOOGLE_PERFTOOLS_FOUND)
target_link_libraries(fgfs profiler)
endif()
target_link_libraries(fgfs
${SQLITE3_LIBRARY}
${SIMGEAR_LIBRARIES}

View file

@ -53,12 +53,15 @@
#include <boost/scoped_array.hpp>
#if GOOGLE_PERFTOOLS_FOUND == YES
# include <google/profiler.h>
#endif
using std::string;
using std::ifstream;
using std::ofstream;
////////////////////////////////////////////////////////////////////////
// Static helper functions.
////////////////////////////////////////////////////////////////////////
@ -1446,7 +1449,48 @@ do_release_cockpit_button (const SGPropertyNode *arg)
return true;
}
// Optional profiling commands using gperftools:
// http://code.google.com/p/gperftools/
#if GOOGLE_PERFTOOLS_FOUND != YES
static void
no_profiling_support()
{
SG_LOG
(
SG_GENERAL,
SG_WARN,
"No profiling support! Install gperftools and reconfigure/rebuild fgfs."
);
}
#endif
static bool
do_profiler_start(const SGPropertyNode *arg)
{
#if GOOGLE_PERFTOOLS_FOUND == YES
const char *filename = arg->getStringValue("filename", "fgfs.profile");
ProfilerStart(filename);
return true;
#else
no_profiling_support();
return false;
#endif
}
static bool
do_profiler_stop(const SGPropertyNode *arg)
{
#if GOOGLE_PERFTOOLS_FOUND == YES
ProfilerStop();
return true;
#else
no_profiling_support();
return false;
#endif
}
////////////////////////////////////////////////////////////////////////
// Command setup.
////////////////////////////////////////////////////////////////////////
@ -1521,6 +1565,11 @@ static struct {
{ "reload-shaders", do_reload_shaders },
{ "reload-materials", do_materials_reload },
#if GOOGLE_PERFTOOLS_FOUND == YES
{ "profiler-start", do_profiler_start },
{ "profiler-stop", do_profiler_stop },
#endif
{ 0, 0 } // zero-terminated
};