From 3c72219c987d5759c94c59caf5aca769e219ce72 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Wed, 23 Apr 2014 14:16:05 +0000 Subject: [PATCH] print commit time in msec to IW's infoStream git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1589423 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/java/org/apache/lucene/index/IndexWriter.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java index 4409e48958f..5ddbb68a1ef 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java @@ -280,6 +280,10 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{ // to allow users to query an IndexWriter settings. private final LiveIndexWriterConfig config; + /** System.nanoTime() when commit started; used to write + * an infoStream message about how long commit took. */ + private long startCommitTime; + DirectoryReader getReader() throws IOException { return getReader(true); } @@ -2743,6 +2747,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{ } private void prepareCommitInternal() throws IOException { + startCommitTime = System.nanoTime(); synchronized(commitLock) { ensureOpen(false); if (infoStream.isEnabled("IW")) { @@ -2968,6 +2973,10 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{ notifyAll(); } + if (infoStream.isEnabled("IW")) { + infoStream.message("IW", String.format(Locale.ROOT, "commit: took %.1f msec", (System.nanoTime()-startCommitTime)/1000000.0)); + } + } else { if (infoStream.isEnabled("IW")) { infoStream.message("IW", "commit: pendingCommit == null; skip");