Index: configure
===================================================================
--- configure	(revision 98d4df99d1a62214a4467c21f220c266138e9826)
+++ configure	(revision ec289484e9e9330811c92a23968e5d2b5ea6062b)
@@ -637,4 +637,8 @@
 LIBOBJS
 CFA_BACKEND_CC
+WITH_LIBTCMALLOC_FALSE
+WITH_LIBTCMALLOC_TRUE
+WITH_LIBPROFILER_FALSE
+WITH_LIBPROFILER_TRUE
 WITH_LIBFIBRE_FALSE
 WITH_LIBFIBRE_TRUE
@@ -3398,4 +3402,5 @@
 		"debug") ;;
 		"nolib") ;;
+		"profile") ;;
 		*)
 			>&2 echo "Configuration must be 'debug', 'nodebug' or 'nolib'"
@@ -16657,4 +16662,106 @@
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ProfilingIsEnabledForAllThreads in -lprofiler" >&5
+$as_echo_n "checking for ProfilingIsEnabledForAllThreads in -lprofiler... " >&6; }
+if ${ac_cv_lib_profiler_ProfilingIsEnabledForAllThreads+:} 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 ProfilingIsEnabledForAllThreads ();
+int
+main ()
+{
+return ProfilingIsEnabledForAllThreads ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_profiler_ProfilingIsEnabledForAllThreads=yes
+else
+  ac_cv_lib_profiler_ProfilingIsEnabledForAllThreads=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_ProfilingIsEnabledForAllThreads" >&5
+$as_echo "$ac_cv_lib_profiler_ProfilingIsEnabledForAllThreads" >&6; }
+if test "x$ac_cv_lib_profiler_ProfilingIsEnabledForAllThreads" = xyes; then :
+  HAVE_LIBPROFILER=1
+else
+  HAVE_LIBPROFILER=0
+fi
+
+ if test "$HAVE_LIBPROFILER" -eq 1; then
+  WITH_LIBPROFILER_TRUE=
+  WITH_LIBPROFILER_FALSE='#'
+else
+  WITH_LIBPROFILER_TRUE='#'
+  WITH_LIBPROFILER_FALSE=
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for malloc in -ltcmalloc" >&5
+$as_echo_n "checking for malloc in -ltcmalloc... " >&6; }
+if ${ac_cv_lib_tcmalloc_malloc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ltcmalloc  $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 malloc ();
+int
+main ()
+{
+return malloc ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_tcmalloc_malloc=yes
+else
+  ac_cv_lib_tcmalloc_malloc=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_tcmalloc_malloc" >&5
+$as_echo "$ac_cv_lib_tcmalloc_malloc" >&6; }
+if test "x$ac_cv_lib_tcmalloc_malloc" = xyes; then :
+  HAVE_LIBTCMALLOC=1
+else
+  HAVE_LIBTCMALLOC=0
+fi
+
+ if test "$HAVE_LIBTCMALLOC" -eq 1; then
+  WITH_LIBTCMALLOC_TRUE=
+  WITH_LIBTCMALLOC_FALSE='#'
+else
+  WITH_LIBTCMALLOC_TRUE='#'
+  WITH_LIBTCMALLOC_FALSE=
+fi
+
+
 # Checks for header files.
 for ac_header in libintl.h malloc.h unistd.h
@@ -16889,4 +16996,12 @@
 if test -z "${WITH_LIBFIBRE_TRUE}" && test -z "${WITH_LIBFIBRE_FALSE}"; then
   as_fn_error $? "conditional \"WITH_LIBFIBRE\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${WITH_LIBPROFILER_TRUE}" && test -z "${WITH_LIBPROFILER_FALSE}"; then
+  as_fn_error $? "conditional \"WITH_LIBPROFILER\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${WITH_LIBTCMALLOC_TRUE}" && test -z "${WITH_LIBTCMALLOC_FALSE}"; then
+  as_fn_error $? "conditional \"WITH_LIBTCMALLOC\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
Index: configure.ac
===================================================================
--- configure.ac	(revision 98d4df99d1a62214a4467c21f220c266138e9826)
+++ configure.ac	(revision ec289484e9e9330811c92a23968e5d2b5ea6062b)
@@ -139,4 +139,5 @@
 		"debug") ;;
 		"nolib") ;;
+		"profile") ;;
 		*)
 			>&2 echo "Configuration must be 'debug', 'nodebug' or 'nolib'"
@@ -190,4 +191,10 @@
 AM_CONDITIONAL([WITH_LIBFIBRE], [test "$HAVE_LIBFIBRE" -eq 1])
 
+AC_CHECK_LIB([profiler], [ProfilingIsEnabledForAllThreads], [HAVE_LIBPROFILER=1], [HAVE_LIBPROFILER=0])
+AM_CONDITIONAL([WITH_LIBPROFILER], [test "$HAVE_LIBPROFILER" -eq 1])
+
+AC_CHECK_LIB([tcmalloc], [malloc], [HAVE_LIBTCMALLOC=1], [HAVE_LIBTCMALLOC=0])
+AM_CONDITIONAL([WITH_LIBTCMALLOC], [test "$HAVE_LIBTCMALLOC" -eq 1])
+
 # Checks for header files.
 AC_CHECK_HEADERS([libintl.h malloc.h unistd.h], [], [echo "Error: Missing required header"; exit 1])
Index: libcfa/configure
===================================================================
--- libcfa/configure	(revision 98d4df99d1a62214a4467c21f220c266138e9826)
+++ libcfa/configure	(revision ec289484e9e9330811c92a23968e5d2b5ea6062b)
@@ -2959,17 +2959,22 @@
 case $CONFIGURATION in
 	"debug"   )
-		CONFIG_CFLAGS="-O0 -g"
+		CONFIG_CFLAGS="-Og -g"
 		CONFIG_CFAFLAGS="-debug"
 		CONFIG_BUILDLIB="yes"
 	;;
 	"nodebug" )
-		CONFIG_CFLAGS="-O2 -s"
+		CONFIG_CFLAGS="-O3 -s"
 		CONFIG_CFAFLAGS="-nodebug"
 		CONFIG_BUILDLIB="yes"
 	;;
 	"nolib"   )
-		CONFIG_CFLAGS="-O2 -s"
+		CONFIG_CFLAGS="-O3 -s"
 		CONFIG_CFAFLAGS="-nolib"
 		CONFIG_BUILDLIB="no"
+	;;
+	"profile" )
+		CONFIG_CFLAGS="-O3 -g -fno-omit-frame-pointer"
+		CONFIG_CFAFLAGS="-nodebug"
+		CONFIG_BUILDLIB="yes"
 	;;
 	*)
Index: libcfa/configure.ac
===================================================================
--- libcfa/configure.ac	(revision 98d4df99d1a62214a4467c21f220c266138e9826)
+++ libcfa/configure.ac	(revision ec289484e9e9330811c92a23968e5d2b5ea6062b)
@@ -45,17 +45,22 @@
 case $CONFIGURATION in
 	"debug"   )
-		CONFIG_CFLAGS="-O0 -g"
+		CONFIG_CFLAGS="-Og -g"
 		CONFIG_CFAFLAGS="-debug"
 		CONFIG_BUILDLIB="yes"
 	;;
 	"nodebug" )
-		CONFIG_CFLAGS="-O2 -s"
+		CONFIG_CFLAGS="-O3 -s"
 		CONFIG_CFAFLAGS="-nodebug"
 		CONFIG_BUILDLIB="yes"
 	;;
 	"nolib"   )
-		CONFIG_CFLAGS="-O2 -s"
+		CONFIG_CFLAGS="-O3 -s"
 		CONFIG_CFAFLAGS="-nolib"
 		CONFIG_BUILDLIB="no"
+	;;
+	"profile" )
+		CONFIG_CFLAGS="-O3 -g -fno-omit-frame-pointer"
+		CONFIG_CFAFLAGS="-nodebug"
+		CONFIG_BUILDLIB="yes"
 	;;
 	*)
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 98d4df99d1a62214a4467c21f220c266138e9826)
+++ src/Makefile.am	(revision ec289484e9e9330811c92a23968e5d2b5ea6062b)
@@ -56,5 +56,13 @@
 ___driver_cfa_cpp_LDADD = -ldl			# yywrap
 
-AM_CXXFLAGS = @HOST_FLAGS@ -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I./Parser -I$(srcdir)/Parser -I$(srcdir)/include -DYY_NO_INPUT -O2 -g -std=c++14
+if WITH_LIBPROFILER
+	___driver_cfa_cpp_LDADD += -lprofiler
+endif
+
+if WITH_LIBTCMALLOC
+	___driver_cfa_cpp_LDADD += -ltcmalloc
+endif
+
+AM_CXXFLAGS = @HOST_FLAGS@ -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I./Parser -I$(srcdir)/Parser -I$(srcdir)/include -DYY_NO_INPUT -O3 -g -std=c++14
 AM_LDFLAGS  = @HOST_FLAGS@ -Xlinker -export-dynamic
 ARFLAGS     = cr
Index: src/Makefile.in
===================================================================
--- src/Makefile.in	(revision 98d4df99d1a62214a4467c21f220c266138e9826)
+++ src/Makefile.in	(revision ec289484e9e9330811c92a23968e5d2b5ea6062b)
@@ -651,5 +651,5 @@
 ___driver_cfa_cpp_SOURCES = $(SRC)
 ___driver_cfa_cpp_LDADD = -ldl			# yywrap
-AM_CXXFLAGS = @HOST_FLAGS@ -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I./Parser -I$(srcdir)/Parser -I$(srcdir)/include -DYY_NO_INPUT -O2 -g -std=c++14
+AM_CXXFLAGS = @HOST_FLAGS@ -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I./Parser -I$(srcdir)/Parser -I$(srcdir)/include -DYY_NO_INPUT -O3 -g -std=c++14
 AM_LDFLAGS = @HOST_FLAGS@ -Xlinker -export-dynamic
 ARFLAGS = cr
@@ -1526,4 +1526,8 @@
 	@rm BasicTypes-gen
 
+@WITH_LIBPROFILER_TRUE@	___driver_cfa_cpp_LDADD += -lprofiler
+
+@WITH_LIBTCMALLOC_TRUE@	___driver_cfa_cpp_LDADD += -ltcmalloc
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
