diff options
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java index 248eaac8ad..27a7347f3a 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java @@ -51,14 +51,18 @@ import static org.eclipse.jgit.lib.Ref.Storage.NEW; import static org.eclipse.jgit.lib.Ref.Storage.PACKED; import java.io.BufferedReader; +import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; +import java.util.List; +import org.eclipse.jgit.internal.storage.file.FileReftableStack; import org.eclipse.jgit.internal.storage.io.BlockSource; import org.eclipse.jgit.internal.storage.reftable.RefCursor; import org.eclipse.jgit.internal.storage.reftable.ReftableReader; +import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectIdRef; import org.eclipse.jgit.lib.Ref; @@ -74,7 +78,8 @@ class BenchmarkReftable extends TextBuiltin { enum Test { SCAN, SEEK_COLD, SEEK_HOT, - BY_ID_COLD, BY_ID_HOT; + BY_ID_COLD, BY_ID_HOT, + WRITE_STACK, } @Option(name = "--tries") @@ -116,6 +121,9 @@ class BenchmarkReftable extends TextBuiltin { case BY_ID_HOT: byIdHot(ObjectId.fromString(objectId)); break; + case WRITE_STACK: + writeStack(); + break; } } @@ -124,6 +132,33 @@ class BenchmarkReftable extends TextBuiltin { } @SuppressWarnings({ "nls", "boxing" }) + private void writeStack() throws Exception { + File dir = new File(reftablePath); + File stackFile = new File(reftablePath + ".stack"); + + dir.mkdirs(); + + long start = System.currentTimeMillis(); + try (FileReftableStack stack = new FileReftableStack(stackFile, dir, + null, () -> new Config())) { + + List<Ref> refs = readLsRemote().asList(); + for (Ref r : refs) { + final long j = stack.getMergedReftable().maxUpdateIndex() + 1; + if (!stack.addReftable(w -> { + w.setMaxUpdateIndex(j).setMinUpdateIndex(j).begin() + .writeRef(r); + })) { + throw new IOException("should succeed"); + } + } + long dt = System.currentTimeMillis() - start; + printf("%12s %10d ms avg %6d us/write", "reftable", dt, + (dt * 1000) / refs.size()); + } + } + + @SuppressWarnings({ "nls", "boxing" }) private void scan() throws Exception { long start, tot; |