Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Main.java @ 243:0e01f9182e16
External cache Nodeid<->int added, Revlog.RevisionMap
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Thu, 23 Jun 2011 16:58:38 +0200 |
| parents | ad6a046943be |
| children | 4b661efb9374 |
comparison
equal
deleted
inserted
replaced
| 242:ad6a046943be | 243:0e01f9182e16 |
|---|---|
| 70 System.out.println("REPO:" + hgRepo.getLocation()); | 70 System.out.println("REPO:" + hgRepo.getLocation()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 public static void main(String[] args) throws Exception { | 73 public static void main(String[] args) throws Exception { |
| 74 Main m = new Main(args); | 74 Main m = new Main(args); |
| 75 m.testRevisionMap(); | |
| 75 // m.testSubrepos(); | 76 // m.testSubrepos(); |
| 76 // m.testReadWorkingCopy(); | 77 // m.testReadWorkingCopy(); |
| 77 // m.testParents(); | 78 // m.testParents(); |
| 78 m.testEffectiveFileLog(); | 79 // m.testEffectiveFileLog(); |
| 79 // m.testCatAtCsetRevision(); | 80 // m.testCatAtCsetRevision(); |
| 80 // m.testMergeState(); | 81 // m.testMergeState(); |
| 81 // m.testFileStatus(); | 82 // m.testFileStatus(); |
| 82 // m.dumpBranches(); | 83 // m.dumpBranches(); |
| 83 // m.inflaterLengthException(); | 84 // m.inflaterLengthException(); |
| 86 // m.testStatusInternals(); | 87 // m.testStatusInternals(); |
| 87 // m.catCompleteHistory(); | 88 // m.catCompleteHistory(); |
| 88 // m.dumpCompleteManifestLow(); | 89 // m.dumpCompleteManifestLow(); |
| 89 // m.dumpCompleteManifestHigh(); | 90 // m.dumpCompleteManifestHigh(); |
| 90 // m.bunchOfTests(); | 91 // m.bunchOfTests(); |
| 92 } | |
| 93 | |
| 94 /* | |
| 95 * cpython repo with 70715 revisions. | |
| 96 3 revisions - 80 ms vs 250 ms (250ms init) | |
| 97 4 revisions - 110 ms vs 265 ms (265 ms init) | |
| 98 5 revisions - 94 vs 266. | |
| 99 complete iteration in changelog.getLocalRevision(tipNodeid) takes 47 ms | |
| 100 compared to complete iteration inside RevisionMap.init() of 171 ms. | |
| 101 The only difference is latter instantiates Nodeids, while former compares binary content as is. | |
| 102 Hence, with 20-30 ms per regular getLocalRevision, it pays off to use RevisionMap with at least 15-20 | |
| 103 queries | |
| 104 */ | |
| 105 private void testRevisionMap() throws Exception { | |
| 106 HgChangelog changelog = hgRepo.getChangelog(); | |
| 107 HgChangelog.RevisionMap rmap = changelog.new RevisionMap().init(); // warm-up, ensure complete file read | |
| 108 int tip = changelog.getLastRevision(); | |
| 109 // take 5 arbitrary revisions at 0, 1/4, 2/4, 3/4 and 4/4 | |
| 110 final Nodeid[] revs = new Nodeid[5]; | |
| 111 revs[4] = changelog.getRevision(0); | |
| 112 revs[3] = changelog.getRevision(tip / 4); | |
| 113 revs[2] = changelog.getRevision(tip / 2); | |
| 114 revs[1] = changelog.getRevision(tip / 4 + tip / 2); | |
| 115 revs[0] = changelog.getRevision(tip); | |
| 116 long start = System.currentTimeMillis(); | |
| 117 for (int i = 0; i < revs.length; i++) { | |
| 118 final int localRev = changelog.getLocalRevision(revs[i]); | |
| 119 System.out.printf("%d:%s\n", localRev, revs[i]); | |
| 120 } | |
| 121 System.out.println(System.currentTimeMillis() - start); | |
| 122 System.out.println(); | |
| 123 // | |
| 124 start = System.currentTimeMillis(); | |
| 125 rmap = changelog.new RevisionMap().init(); | |
| 126 long s2 = System.currentTimeMillis(); | |
| 127 for (int i = 0; i < revs.length; i++) { | |
| 128 final int localRev = rmap.localRevision(revs[i]); | |
| 129 System.out.printf("%d:%s\n", localRev, revs[i]); | |
| 130 } | |
| 131 System.out.println(System.currentTimeMillis() - start); | |
| 132 System.out.printf("\t from that, init took %d ms\n", s2 - start); | |
| 133 | |
| 91 } | 134 } |
| 92 | 135 |
| 93 private void testSubrepos() throws Exception { | 136 private void testSubrepos() throws Exception { |
| 94 for (HgSubrepoLocation l : hgRepo.getSubrepositories()) { | 137 for (HgSubrepoLocation l : hgRepo.getSubrepositories()) { |
| 95 System.out.println(l.getLocation()); | 138 System.out.println(l.getLocation()); |
