1
1
/*
2
+ * Elemental
3
+ * Copyright (C) 2024, Evolved Binary Ltd
4
+ *
5
+
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
+ *
2
26
* eXist-db Open Source Native XML Database
3
27
* Copyright (C) 2001 The eXist-db Authors
4
28
*
19
43
* License along with this library; if not, write to the Free Software
20
44
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
45
*/
22
-
23
46
package org .exist .xquery ;
24
47
25
48
import org .apache .commons .io .output .StringBuilderWriter ;
@@ -317,9 +340,10 @@ private FunctionStats[] sort() {
317
340
return stats ;
318
341
}
319
342
320
- public synchronized void toXML (MemTreeBuilder builder ) {
343
+ public synchronized void toXML (final MemTreeBuilder builder ) {
321
344
final AttributesImpl attrs = new AttributesImpl ();
322
- builder .startElement (new QName ("calls" , XML_NAMESPACE , XML_PREFIX ), null );
345
+ attrs .addAttribute ("" , "tracing-enabled" , "tracing-enabled" , "CDATA" , Boolean .toString (isEnabled ()));
346
+ builder .startElement (new QName ("calls" , XML_NAMESPACE , XML_PREFIX ), attrs );
323
347
for (final QueryStats stats : queries .values ()) {
324
348
attrs .clear ();
325
349
attrs .addAttribute ("" , "source" , "source" , "CDATA" , stats .source );
@@ -333,20 +357,19 @@ public synchronized void toXML(MemTreeBuilder builder) {
333
357
attrs .addAttribute ("" , "name" , "name" , "CDATA" , stats .qname .getStringValue ());
334
358
attrs .addAttribute ("" , "elapsed" , "elapsed" , "CDATA" , Double .toString (stats .executionTime / 1000.0 ));
335
359
attrs .addAttribute ("" , "calls" , "calls" , "CDATA" , Integer .toString (stats .callCount ));
336
- if (stats .source != null )
337
- {attrs .addAttribute ("" , "source" , "source" , "CDATA" , stats .source );}
360
+ if (stats .source != null ) {
361
+ attrs .addAttribute ("" , "source" , "source" , "CDATA" , stats .source );
362
+ }
338
363
builder .startElement (new QName ("function" , XML_NAMESPACE , XML_PREFIX ), attrs );
339
364
builder .endElement ();
340
365
}
341
366
for (final IndexStats stats : indexStats .values ()) {
342
367
attrs .clear ();
343
368
attrs .addAttribute ("" , "type" , "type" , "CDATA" , stats .indexType );
344
- attrs .addAttribute ("" , "source" , "source" , "CDATA" , stats .source + " [" + stats .line + ":" +
345
- stats .column + "]" );
369
+ attrs .addAttribute ("" , "source" , "source" , "CDATA" , stats .source + " [" + stats .line + ":" + stats .column + "]" );
346
370
attrs .addAttribute ("" , "elapsed" , "elapsed" , "CDATA" , Double .toString (stats .executionTime / 1000.0 ));
347
371
attrs .addAttribute ("" , "calls" , "calls" , "CDATA" , Integer .toString (stats .usageCount ));
348
- attrs .addAttribute ("" , "optimization" , "optimization" , "CDATA" ,
349
- Integer .toString (stats .mode ));
372
+ attrs .addAttribute ("" , "optimization" , "optimization" , "CDATA" , Integer .toString (stats .mode ));
350
373
builder .startElement (new QName ("index" , XML_NAMESPACE , XML_PREFIX ), attrs );
351
374
builder .endElement ();
352
375
}
0 commit comments