Skip to content

Commit 865a485

Browse files
committed
add elapsed time reporting for 2nd phase of indexing and report total time as well
1 parent 39c745d commit 865a485

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/org/opensolaris/opengrok/index/IndexDatabase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public void update() throws IOException, HistoryException {
322322
}
323323
}
324324

325-
try {
325+
try {
326326
Analyzer analyzer = AnalyzerGuru.getAnalyzer();
327327
IndexWriterConfig iwc = new IndexWriterConfig(SearchEngine.LUCENE_VERSION, analyzer);
328328
iwc.setOpenMode(OpenMode.CREATE_OR_APPEND);

src/org/opensolaris/opengrok/index/Indexer.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import org.opensolaris.opengrok.util.Executor;
5757
import org.opensolaris.opengrok.util.Getopt;
5858
import org.opensolaris.opengrok.util.Statistics;
59+
import org.opensolaris.opengrok.util.StringUtils;
5960

6061
/**
6162
* Creates and updates an inverted source index as well as generates Xref, file
@@ -548,6 +549,7 @@ public static void main(String argv[]) {
548549
System.out.println("History stored in DB and renamed file handling is on - possible performance degradation");
549550
}
550551

552+
long start = System.currentTimeMillis();
551553
getInstance().prepareIndexer(env, searchRepositories, addProjects,
552554
defaultProject, configFilename, refreshHistory,
553555
listFiles, createDict, subFiles, repositories,
@@ -560,6 +562,9 @@ public static void main(String argv[]) {
560562
getInstance().doIndexerExecution(update, noThreads, subFiles,
561563
progress);
562564
}
565+
long stop = System.currentTimeMillis();
566+
String time_str = StringUtils.getReadableTime(stop - start);
567+
log.log(Level.INFO, "Total indexing time: {0})", time_str);
563568
getInstance().sendToConfigHost(env, configHost);
564569
} catch (IndexerException ex) {
565570
log.log(Level.SEVERE, "Exception running indexer", ex);
@@ -577,8 +582,14 @@ public static void main(String argv[]) {
577582

578583
}
579584

580-
// PMD wants us to use length() > 0 && charAt(0) instead of startsWith()
581-
// for performance. We prefer clarity over performance here, so silence it.
585+
/*
586+
* This is the first phase of the indexing where history cache is being
587+
* generated for repositories (at least for those which support getting
588+
* history per directory).
589+
*
590+
* PMD wants us to use length() > 0 && charAt(0) instead of startsWith()
591+
* for performance. We prefer clarity over performance here, so silence it.
592+
*/
582593
@SuppressWarnings("PMD.SimplifyStartsWith")
583594
public void prepareIndexer(RuntimeEnvironment env,
584595
boolean searchRepositories,
@@ -743,9 +754,16 @@ public int compare(Project p1, Project p2) {
743754
}
744755
}
745756

757+
/*
758+
* This is the second phase of the indexer which generates Lucene index
759+
* by passing source code files through Exuberant ctags, generating xrefs
760+
* and storing data from the source files in the index (along with history,
761+
* if any).
762+
*/
746763
public void doIndexerExecution(final boolean update, int noThreads, List<String> subFiles,
747764
IndexChangedListener progress)
748765
throws IOException {
766+
long start = System.currentTimeMillis();
749767
RuntimeEnvironment env = RuntimeEnvironment.getInstance().register();
750768
log.info("Starting indexing");
751769

@@ -826,7 +844,10 @@ public void run() {
826844
log.log(Level.SEVERE,
827845
"destroying of renamed thread pool failed", ex);
828846
}
829-
log.info("Done indexing");
847+
long stop = System.currentTimeMillis();
848+
String time_str = StringUtils.getReadableTime(stop - start);
849+
log.log(Level.INFO, "Done indexing data of all repositories (took {0})",
850+
time_str);
830851
}
831852

832853
public void sendToConfigHost(RuntimeEnvironment env, String configHost) {

0 commit comments

Comments
 (0)