Skip to content

Commit 2492ee3

Browse files
committed
[bugfix] Allow previously collected Performance Stats to be serialized
1 parent 9118e60 commit 2492ee3

2 files changed

Lines changed: 34 additions & 9 deletions

File tree

exist-core/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@
870870
<include>src/main/java/org/exist/xquery/ErrorCodes.java</include>
871871
<include>src/main/java/org/exist/xquery/FunctionFactory.java</include>
872872
<include>src/main/java/org/exist/xquery/Optimizer.java</include>
873+
<include>src/main/java/org/exist/xquery/PerformanceStats.java</include>
873874
<include>src/main/java/org/exist/xquery/UserDefinedFunction.java</include>
874875
<include>src/main/java/org/exist/xquery/XPathUtil.java</include>
875876
<include>src/main/java/org/exist/xquery/XQueryContext.java</include>
@@ -1160,6 +1161,7 @@
11601161
<exclude>src/main/java/org/exist/xquery/Materializable.java</exclude>
11611162
<exclude>src/main/java/org/exist/xquery/NameTest.java</exclude>
11621163
<exclude>src/main/java/org/exist/xquery/Optimizer.java</exclude>
1164+
<exclude>src/main/java/org/exist/xquery/PerformanceStats.java</exclude>
11631165
<exclude>src/main/java/org/exist/xquery/UserDefinedFunction.java</exclude>
11641166
<exclude>src/test/java/org/exist/xquery/WatchdogTest.java</exclude>
11651167
<exclude>src/main/java/org/exist/xquery/XPathUtil.java</exclude>

exist-core/src/main/java/org/exist/xquery/PerformanceStats.java

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
/*
2+
* Elemental
3+
* Copyright (C) 2024, Evolved Binary Ltd
4+
*
5+
* admin@evolvedbinary.com
6+
* https://www.evolvedbinary.com | https://www.elemental.xyz
7+
*
8+
* This library is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU Lesser General Public
10+
* License as published by the Free Software Foundation; version 2.1.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+
* The original license header is included below.
23+
*
24+
* =====================================================================
25+
*
226
* eXist-db Open Source Native XML Database
327
* Copyright (C) 2001 The eXist-db Authors
428
*
@@ -19,7 +43,6 @@
1943
* License along with this library; if not, write to the Free Software
2044
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2145
*/
22-
2346
package org.exist.xquery;
2447

2548
import org.exist.Database;
@@ -316,9 +339,10 @@ private FunctionStats[] sort() {
316339
return stats;
317340
}
318341

319-
public synchronized void toXML(MemTreeBuilder builder) {
342+
public synchronized void toXML(final MemTreeBuilder builder) {
320343
final AttributesImpl attrs = new AttributesImpl();
321-
builder.startElement(new QName("calls", XML_NAMESPACE, XML_PREFIX), null);
344+
attrs.addAttribute("", "tracing-enabled", "tracing-enabled", "CDATA", Boolean.toString(isEnabled()));
345+
builder.startElement(new QName("calls", XML_NAMESPACE, XML_PREFIX), attrs);
322346
for (final QueryStats stats : queries.values()) {
323347
attrs.clear();
324348
attrs.addAttribute("", "source", "source", "CDATA", stats.source);
@@ -332,20 +356,19 @@ public synchronized void toXML(MemTreeBuilder builder) {
332356
attrs.addAttribute("", "name", "name", "CDATA", stats.qname.getStringValue());
333357
attrs.addAttribute("", "elapsed", "elapsed", "CDATA", Double.toString(stats.executionTime / 1000.0));
334358
attrs.addAttribute("", "calls", "calls", "CDATA", Integer.toString(stats.callCount));
335-
if (stats.source != null)
336-
{attrs.addAttribute("", "source", "source", "CDATA", stats.source);}
359+
if (stats.source != null) {
360+
attrs.addAttribute("", "source", "source", "CDATA", stats.source);
361+
}
337362
builder.startElement(new QName("function", XML_NAMESPACE, XML_PREFIX), attrs);
338363
builder.endElement();
339364
}
340365
for (final IndexStats stats: indexStats.values()) {
341366
attrs.clear();
342367
attrs.addAttribute("", "type", "type", "CDATA", stats.indexType);
343-
attrs.addAttribute("", "source", "source", "CDATA", stats.source + " [" + stats.line + ":" +
344-
stats.column + "]");
368+
attrs.addAttribute("", "source", "source", "CDATA", stats.source + " [" + stats.line + ":" + stats.column + "]");
345369
attrs.addAttribute("", "elapsed", "elapsed", "CDATA", Double.toString(stats.executionTime / 1000.0));
346370
attrs.addAttribute("", "calls", "calls", "CDATA", Integer.toString(stats.usageCount));
347-
attrs.addAttribute("", "optimization", "optimization", "CDATA",
348-
Integer.toString(stats.mode));
371+
attrs.addAttribute("", "optimization", "optimization", "CDATA", Integer.toString(stats.mode));
349372
builder.startElement(new QName("index", XML_NAMESPACE, XML_PREFIX), attrs);
350373
builder.endElement();
351374
}

0 commit comments

Comments
 (0)