Add debug trace to measure time needed to open pack index

Change-Id: Ia698cc06aa3fe6cb7903a687db8885f1b83c3bf2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2019-06-04 15:46:44 +02:00
parent 9a7d3b053a
commit b5c594216b
1 changed files with 13 additions and 0 deletions

View File

@ -93,6 +93,8 @@
import org.eclipse.jgit.util.LongList;
import org.eclipse.jgit.util.NB;
import org.eclipse.jgit.util.RawParseUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A Git version 2 pack file representation. A pack file contains Git objects in
@ -100,6 +102,7 @@
* objects are similar.
*/
public class PackFile implements Iterable<PackIndex.MutableEntry> {
private final static Logger LOG = LoggerFactory.getLogger(PackFile.class);
/** Sorts PackFiles to be most recently created to least recently created. */
public static final Comparator<PackFile> SORT = new Comparator<PackFile>() {
@Override
@ -189,7 +192,17 @@ private PackIndex idx() throws IOException {
throw new PackInvalidException(packFile, invalidatingCause);
}
try {
long start = System.currentTimeMillis();
idx = PackIndex.open(extFile(INDEX));
if (LOG.isDebugEnabled()) {
LOG.debug(String.format(
"Opening pack index %s, size %.3f MB took %d ms", //$NON-NLS-1$
extFile(INDEX).getAbsolutePath(),
Float.valueOf(extFile(INDEX).length()
/ (1024f * 1024)),
Long.valueOf(System.currentTimeMillis()
- start)));
}
if (packChecksum == null) {
packChecksum = idx.packChecksum;