[libxslt] Make profiler support optional
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxslt] Make profiler support optional
- Date: Sun, 12 May 2019 13:52:13 +0000 (UTC)
commit 895c668b49693e9a6584ba08664436fd43986830
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Sat May 11 14:25:56 2019 +0200
Make profiler support optional
configure.ac | 14 ++++++++++++++
libxslt/transform.c | 28 ++++++++++++++++++++++++++--
libxslt/xsltconfig.h.in | 13 +++++++++++++
libxslt/xsltutils.c | 25 +++++++++++++++++++++++++
4 files changed, 78 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 027081a3..f932049c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -402,6 +402,20 @@ else
fi
AC_SUBST(WITH_DEBUGGER)
+dnl
+dnl Is profiler support requested
+dnl
+AC_ARG_WITH(profiler, [ --with-profiler Add the profiling support (on)])
+if test "$with_profiler" = "no" ; then
+ echo Disabling profiler
+ WITH_PROFILER=0
+else
+ echo Enabling profiler
+ WITH_PROFILER=1
+ AC_DEFINE([WITH_PROFILER],[], [Define if profiling support is enabled])
+fi
+AC_SUBST(WITH_PROFILER)
+
dnl
dnl The following new parameters were added to offer
dnl the ability to specify the location of the libxml
diff --git a/libxslt/transform.c b/libxslt/transform.c
index a9952c8d..cf6ce671 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -232,6 +232,8 @@ xsltTemplateParamsCleanup(xsltTransformContextPtr ctxt)
ctxt->vars = NULL;
}
+#ifdef WITH_PROFILER
+
/**
* profPush:
* @ctxt: the transformation context
@@ -340,6 +342,8 @@ profCallgraphAdd(xsltTemplatePtr templ, xsltTemplatePtr parent)
}
}
+#endif /* WITH_PROFILER */
+
/**
* xsltPreCompEval:
* @ctxt: transform context
@@ -3099,10 +3103,12 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
xsltStackElemPtr withParams)
{
int oldVarsBase = 0;
- long start = 0;
xmlNodePtr cur;
xsltStackElemPtr tmpParam = NULL;
xmlDocPtr oldUserFragmentTop;
+#ifdef WITH_PROFILER
+ long start = 0;
+#endif
#ifdef XSLT_REFACTORED
xsltStyleItemParamPtr iparam;
@@ -3157,12 +3163,16 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
ctxt->varsBase = ctxt->varsNr;
ctxt->node = contextNode;
+
+#ifdef WITH_PROFILER
if (ctxt->profile) {
templ->nbCalls++;
start = xsltTimestamp();
profPush(ctxt, 0);
profCallgraphAdd(templ, ctxt->templ);
}
+#endif
+
/*
* Push the xsl:template declaration onto the stack.
*/
@@ -3270,6 +3280,8 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
* Pop the xsl:template declaration from the stack.
*/
templPop(ctxt);
+
+#ifdef WITH_PROFILER
if (ctxt->profile) {
long spent, child, total, end;
@@ -3290,6 +3302,7 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
if (ctxt->profNr > 0)
ctxt->profTab[ctxt->profNr - 1] += total;
}
+#endif
#ifdef WITH_DEBUGGER
if ((ctxt->debugStatus != XSLT_DEBUG_NONE) && (addCallResult)) {
@@ -5911,8 +5924,16 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
ctxt->initialContextDoc = doc;
ctxt->initialContextNode = (xmlNodePtr) doc;
- if (profile != NULL)
+ if (profile != NULL) {
+#ifdef WITH_PROFILER
ctxt->profile = 1;
+#else
+ xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
+ "xsltApplyStylesheetInternal: "
+ "libxslt compiled without profiler\n");
+ goto error;
+#endif
+ }
if (output != NULL)
ctxt->outputFile = output;
@@ -6187,9 +6208,12 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
}
}
xmlXPathFreeNodeSet(ctxt->nodeList);
+
+#ifdef WITH_PROFILER
if (profile != NULL) {
xsltSaveProfiling(ctxt, profile);
}
+#endif
/*
* Be pedantic.
diff --git a/libxslt/xsltconfig.h.in b/libxslt/xsltconfig.h.in
index f381ded2..726e444d 100644
--- a/libxslt/xsltconfig.h.in
+++ b/libxslt/xsltconfig.h.in
@@ -110,6 +110,19 @@ extern "C" {
#endif
#endif
+/**
+ * WITH_PROFILER:
+ *
+ * Activate the compilation of the profiler. Speed penalty
+ * is insignifiant.
+ * On by default unless --without-profiler is passed to configure
+ */
+#if @WITH_PROFILER@
+#ifndef WITH_PROFILER
+#define WITH_PROFILER
+#endif
+#endif
+
/**
* WITH_MODULES:
*
diff --git a/libxslt/xsltutils.c b/libxslt/xsltutils.c
index 74bd6f0f..231652fc 100644
--- a/libxslt/xsltutils.c
+++ b/libxslt/xsltutils.c
@@ -1798,6 +1798,8 @@ xsltSaveResultToString(xmlChar **doc_txt_ptr, int * doc_txt_len,
return 0;
}
+#ifdef WITH_PROFILER
+
/************************************************************************
* *
* Generating profiling information *
@@ -2275,6 +2277,29 @@ xsltGetProfileInformation(xsltTransformContextPtr ctxt)
return ret;
}
+#else /* WITH_PROFILER */
+
+void
+xsltCalibrateAdjust(long delta ATTRIBUTE_UNUSED) {
+}
+
+long
+xsltTimestamp(void) {
+ return(0);
+}
+
+void
+xsltSaveProfiling(xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED,
+ FILE *output ATTRIBUTE_UNUSED) {
+}
+
+xmlDocPtr
+xsltGetProfileInformation(xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED) {
+ return(NULL);
+}
+
+#endif /* WITH_PROFILER */
+
/************************************************************************
* *
* Hooks for libxml2 XPath *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]