119119import org .opengrok .indexer .logger .LoggerFactory ;
120120import org .opengrok .indexer .search .QueryBuilder ;
121121import org .opengrok .indexer .util .IOUtils ;
122+ import org .opengrok .indexer .util .Statistics ;
122123import org .opengrok .indexer .web .Util ;
123124
124125/**
@@ -658,12 +659,15 @@ private static void populateDocumentHistory(Document doc, File file) {
658659 * @param defs definitions for the source file, if available
659660 * @param annotation Annotation information for the file
660661 * @param project Project the file belongs to
662+ * @param file file object, used only for logging
661663 * @throws java.io.IOException If an error occurs while creating the output
662664 */
663665 public static void writeXref (AnalyzerFactory factory , Reader in ,
664666 Writer out , Definitions defs ,
665- Annotation annotation , Project project )
667+ Annotation annotation , Project project , File file )
666668 throws IOException {
669+
670+ Statistics stat = new Statistics ();
667671 Reader input = in ;
668672 if (factory .getGenre () == AbstractAnalyzer .Genre .PLAIN ) {
669673 // This is some kind of text file, so we need to expand tabs to
@@ -681,13 +685,14 @@ public static void writeXref(AnalyzerFactory factory, Reader in,
681685 analyzer .setScopesEnabled (env .isScopesEnabled ());
682686 analyzer .setFoldingEnabled (env .isFoldingEnabled ());
683687 analyzer .writeXref (args );
688+
689+ stat .report (LOGGER , Level .FINEST , String .format ("wrote xref for '%s'" , file ), "xref.write.latency" );
684690 }
685691
686692 /**
687- * Writes a browse-able version of the file transformed for immediate
688- * serving to a web client.
693+ * Writes a browse-able version of the file transformed for immediate serving to a web client.
689694 * @param contextPath the web context path for
690- * {@link Util#dumpXref(java.io.Writer, java.io.Reader, java.lang.String)}
695+ * {@link Util#dumpXref(java.io.Writer, java.io.Reader, java.lang.String, File )}
691696 * @param factory the analyzer factory for this file type
692697 * @param in the input stream containing the data
693698 * @param out a defined instance to write
@@ -698,13 +703,12 @@ public static void writeXref(AnalyzerFactory factory, Reader in,
698703 */
699704 public static void writeDumpedXref (String contextPath ,
700705 AnalyzerFactory factory , Reader in , Writer out ,
701- Definitions defs , Annotation annotation , Project project )
702- throws IOException {
706+ Definitions defs , Annotation annotation , Project project , File file ) throws IOException {
703707
704708 File xrefTemp = File .createTempFile ("ogxref" , ".html" );
705709 try {
706710 try (FileWriter tmpout = new FileWriter (xrefTemp )) {
707- writeXref (factory , in , tmpout , defs , annotation , project );
711+ writeXref (factory , in , tmpout , defs , annotation , project , file );
708712 }
709713 Util .dumpXref (out , xrefTemp , false , contextPath );
710714 } finally {
0 commit comments