Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java22
1 files changed, 18 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
index 4586370d6b..d66b3acbdf 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
@@ -255,6 +255,8 @@ public final class DfsPackFile {
PackIndex idx;
try {
+ ctx.stats.readIdx++;
+ long start = System.nanoTime();
ReadableChannel rc = ctx.db.openFile(packDesc, INDEX);
try {
InputStream in = Channels.newInputStream(rc);
@@ -264,10 +266,11 @@ public final class DfsPackFile {
bs = (wantSize / bs) * bs;
else if (bs <= 0)
bs = wantSize;
- in = new BufferedInputStream(in, bs);
- idx = PackIndex.read(in);
+ idx = PackIndex.read(new BufferedInputStream(in, bs));
+ ctx.stats.readIdxBytes += rc.position();
} finally {
rc.close();
+ ctx.stats.readIdxMicros += elapsedMicros(start);
}
} catch (EOFException e) {
invalid = true;
@@ -292,6 +295,10 @@ public final class DfsPackFile {
}
}
+ private static long elapsedMicros(long start) {
+ return (System.nanoTime() - start) / 1000L;
+ }
+
final boolean isGarbage() {
return packDesc.getPackSource() == UNREACHABLE_GARBAGE;
}
@@ -320,6 +327,8 @@ public final class DfsPackFile {
long size;
PackBitmapIndex idx;
try {
+ ctx.stats.readBitmap++;
+ long start = System.nanoTime();
ReadableChannel rc = ctx.db.openFile(packDesc, BITMAP_INDEX);
try {
InputStream in = Channels.newInputStream(rc);
@@ -335,6 +344,8 @@ public final class DfsPackFile {
} finally {
size = rc.position();
rc.close();
+ ctx.stats.readIdxBytes += size;
+ ctx.stats.readIdxMicros += elapsedMicros(start);
}
} catch (EOFException e) {
IOException e2 = new IOException(MessageFormat.format(
@@ -786,6 +797,8 @@ public final class DfsPackFile {
throw new PackInvalidException(getPackName(), invalidatingCause);
}
+ ctx.stats.readBlock++;
+ long start = System.nanoTime();
ReadableChannel rc = ctx.db.openFile(packDesc, PACK);
try {
int size = blockSize(rc);
@@ -812,6 +825,7 @@ public final class DfsPackFile {
byte[] buf = new byte[size];
rc.position(pos);
int cnt = read(rc, ByteBuffer.wrap(buf, 0, size));
+ ctx.stats.readBlockBytes += cnt;
if (cnt != size) {
if (0 <= len) {
throw new EOFException(MessageFormat.format(
@@ -833,10 +847,10 @@ public final class DfsPackFile {
length = len = rc.size();
}
- DfsBlock v = new DfsBlock(key, pos, buf);
- return v;
+ return new DfsBlock(key, pos, buf);
} finally {
rc.close();
+ ctx.stats.readBlockMicros += elapsedMicros(start);
}
}

Back to the top