From b5c594216ba1a462796e5e4d8d929062db143768 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Tue, 4 Jun 2019 15:46:44 +0200 Subject: [PATCH] Add debug trace to measure time needed to open pack index Change-Id: Ia698cc06aa3fe6cb7903a687db8885f1b83c3bf2 Signed-off-by: Matthias Sohn --- .../jgit/internal/storage/file/PackFile.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java index 7313305c9..73ad38c95 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java @@ -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 { + private final static Logger LOG = LoggerFactory.getLogger(PackFile.class); /** Sorts PackFiles to be most recently created to least recently created. */ public static final Comparator SORT = new Comparator() { @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;