better profiling

This commit is contained in:
Markus Gans 2015-10-15 02:37:02 +02:00
parent 62890f6ecc
commit 78a1c0cb85
5 changed files with 75 additions and 2 deletions

View File

@ -16,6 +16,10 @@ case "$1" in
./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -pg -O0 -DDEBUG -W -Wall -pedantic" ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -pg -O0 -DDEBUG -W -Wall -pedantic"
;; ;;
"--cpu-profiler"|"cpu-profiler")
./configure --prefix="$PREFIX" --with-profiler
;;
"--gcov"|"gcov") "--gcov"|"gcov")
./configure --prefix="$PREFIX" CXXFLAGS="-fprofile-arcs -ftest-coverage" ./configure --prefix="$PREFIX" CXXFLAGS="-fprofile-arcs -ftest-coverage"
;; ;;
@ -33,6 +37,7 @@ case "$1" in
echo " debug Compile with debug option" echo " debug Compile with debug option"
echo " fulldebug Compile with all warning options" echo " fulldebug Compile with all warning options"
echo " profile Compile with profile option (analysis with gprof)" echo " profile Compile with profile option (analysis with gprof)"
echo " cpu-profiler Link with Google cpu performance profiler"
echo " gcov Compile with options for coverage analysis with gcov" echo " gcov Compile with options for coverage analysis with gcov"
echo " release Compile for release" echo " release Compile for release"
exit 1 exit 1

55
configure vendored
View File

@ -767,6 +767,7 @@ with_gnu_ld
with_sysroot with_sysroot
enable_libtool_lock enable_libtool_lock
with_gpm with_gpm
with_profiler
' '
ac_precious_vars='build_alias ac_precious_vars='build_alias
host_alias host_alias
@ -1420,6 +1421,7 @@ Optional Packages:
--with-sysroot=DIR Search for dependent libraries within DIR --with-sysroot=DIR Search for dependent libraries within DIR
(or the compiler's sysroot if not specified). (or the compiler's sysroot if not specified).
--without-gpm Disable GPM mouse support --without-gpm Disable GPM mouse support
--with-profiler build extra google profiler binaries
Some influential environment variables: Some influential environment variables:
CC C compiler command CC C compiler command
@ -16906,6 +16908,59 @@ $as_echo "#define HAVE_LIBGPM 1" >>confdefs.h
fi fi
# profiling
# Check whether --with-profiler was given.
if test "${with_profiler+set}" = set; then :
withval=$with_profiler; with_profiler=yes
else
with_profiler=no
fi
if test "x$with_profiler" = "xyes"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ProfilerFlush in -lprofiler" >&5
$as_echo_n "checking for ProfilerFlush in -lprofiler... " >&6; }
if ${ac_cv_lib_profiler_ProfilerFlush+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lprofiler $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char ProfilerFlush ();
int
main ()
{
return ProfilerFlush ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_profiler_ProfilerFlush=yes
else
ac_cv_lib_profiler_ProfilerFlush=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_profiler_ProfilerFlush" >&5
$as_echo "$ac_cv_lib_profiler_ProfilerFlush" >&6; }
if test "x$ac_cv_lib_profiler_ProfilerFlush" = xyes; then :
LIBS="$LIBS -lprofiler"
fi
fi
cat >confcache <<\_ACEOF cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure # This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure # tests run on this system so they can be shared between configure

View File

@ -69,4 +69,16 @@ then
AC_DEFINE([HAVE_LIBGPM], 1, [Define to 1 if GPM mouse is enabled]) AC_DEFINE([HAVE_LIBGPM], 1, [Define to 1 if GPM mouse is enabled])
fi fi
# profiling
AC_ARG_WITH([profiler],
[AS_HELP_STRING([--with-profiler], [build extra google profiler binaries])],
[with_profiler=yes],
[with_profiler=no])
if test "x$with_profiler" = "xyes"
then
AC_CHECK_LIB([profiler],
[ProfilerFlush],
[LIBS="$LIBS -lprofiler"])
fi
AC_OUTPUT AC_OUTPUT

View File

@ -2,4 +2,5 @@
LD_LIBRARY_PATH=../src/.libs/ LD_PRELOAD="/usr/lib64/libprofiler.so.0" CPUPROFILE=../test/.libs/ui.prof ../test/.libs/ui LD_LIBRARY_PATH=../src/.libs/ LD_PRELOAD="/usr/lib64/libprofiler.so.0" CPUPROFILE=../test/.libs/ui.prof ../test/.libs/ui
pprof --gv ../test/.libs/ui ../test/.libs/ui.prof pprof --gv ../test/.libs/ui ../test/.libs/ui.prof
rm -f ../test/.libs/ui.prof