Mercurial > hg4j
comparison cmdline/org/tmatesoft/hg/console/Main.java @ 254:a620f0663a37
Collect tags for a file - improve performance of 'sparse' manifest reads
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 16 Aug 2011 04:03:29 +0200 |
parents | 1874d11054e5 |
children | c6450b0b1fd5 |
comparison
equal
deleted
inserted
replaced
253:1874d11054e5 | 254:a620f0663a37 |
---|---|
16 */ | 16 */ |
17 package org.tmatesoft.hg.console; | 17 package org.tmatesoft.hg.console; |
18 | 18 |
19 import static org.tmatesoft.hg.repo.HgRepository.TIP; | 19 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
20 | 20 |
21 import java.io.File; | |
21 import java.util.ArrayList; | 22 import java.util.ArrayList; |
22 import java.util.Collections; | 23 import java.util.Collections; |
23 import java.util.List; | 24 import java.util.List; |
24 import java.util.Map; | 25 import java.util.Map; |
25 | 26 |
31 import org.tmatesoft.hg.core.HgManifestCommand; | 32 import org.tmatesoft.hg.core.HgManifestCommand; |
32 import org.tmatesoft.hg.core.Nodeid; | 33 import org.tmatesoft.hg.core.Nodeid; |
33 import org.tmatesoft.hg.internal.ByteArrayChannel; | 34 import org.tmatesoft.hg.internal.ByteArrayChannel; |
34 import org.tmatesoft.hg.internal.DigestHelper; | 35 import org.tmatesoft.hg.internal.DigestHelper; |
35 import org.tmatesoft.hg.internal.PathGlobMatcher; | 36 import org.tmatesoft.hg.internal.PathGlobMatcher; |
37 import org.tmatesoft.hg.internal.RelativePathRewrite; | |
36 import org.tmatesoft.hg.repo.HgBranches; | 38 import org.tmatesoft.hg.repo.HgBranches; |
37 import org.tmatesoft.hg.repo.HgChangelog; | 39 import org.tmatesoft.hg.repo.HgChangelog; |
38 import org.tmatesoft.hg.repo.HgDataFile; | 40 import org.tmatesoft.hg.repo.HgDataFile; |
39 import org.tmatesoft.hg.repo.HgInternals; | 41 import org.tmatesoft.hg.repo.HgInternals; |
40 import org.tmatesoft.hg.repo.HgManifest; | 42 import org.tmatesoft.hg.repo.HgManifest; |
44 import org.tmatesoft.hg.repo.HgStatusInspector; | 46 import org.tmatesoft.hg.repo.HgStatusInspector; |
45 import org.tmatesoft.hg.repo.HgSubrepoLocation; | 47 import org.tmatesoft.hg.repo.HgSubrepoLocation; |
46 import org.tmatesoft.hg.repo.HgSubrepoLocation.Kind; | 48 import org.tmatesoft.hg.repo.HgSubrepoLocation.Kind; |
47 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; | 49 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; |
48 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; | 50 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; |
51 import org.tmatesoft.hg.util.FileIterator; | |
52 import org.tmatesoft.hg.util.FileWalker; | |
49 import org.tmatesoft.hg.util.Pair; | 53 import org.tmatesoft.hg.util.Pair; |
50 import org.tmatesoft.hg.util.Path; | 54 import org.tmatesoft.hg.util.Path; |
55 import org.tmatesoft.hg.util.PathRewrite; | |
51 | 56 |
52 /** | 57 /** |
53 * Various debug dumps. | 58 * Various debug dumps. |
54 * | 59 * |
55 * @author Artem Tikhomirov | 60 * @author Artem Tikhomirov |
70 System.out.println("REPO:" + hgRepo.getLocation()); | 75 System.out.println("REPO:" + hgRepo.getLocation()); |
71 } | 76 } |
72 | 77 |
73 public static void main(String[] args) throws Exception { | 78 public static void main(String[] args) throws Exception { |
74 Main m = new Main(args); | 79 Main m = new Main(args); |
80 m.testTreeTraversal(); | |
75 // m.testRevisionMap(); | 81 // m.testRevisionMap(); |
76 // m.testSubrepos(); | 82 // m.testSubrepos(); |
77 // m.testReadWorkingCopy(); | 83 // m.testReadWorkingCopy(); |
78 m.testParents(); | 84 // m.testParents(); |
79 // m.testEffectiveFileLog(); | 85 // m.testEffectiveFileLog(); |
80 // m.testCatAtCsetRevision(); | 86 // m.testCatAtCsetRevision(); |
81 // m.testMergeState(); | 87 // m.testMergeState(); |
82 // m.testFileStatus(); | 88 // m.testFileStatus(); |
83 // m.dumpBranches(); | 89 // m.dumpBranches(); |
87 // m.testStatusInternals(); | 93 // m.testStatusInternals(); |
88 // m.catCompleteHistory(); | 94 // m.catCompleteHistory(); |
89 // m.dumpCompleteManifestLow(); | 95 // m.dumpCompleteManifestLow(); |
90 // m.dumpCompleteManifestHigh(); | 96 // m.dumpCompleteManifestHigh(); |
91 // m.bunchOfTests(); | 97 // m.bunchOfTests(); |
98 } | |
99 | |
100 private void testTreeTraversal() throws Exception { | |
101 File repoRoot = hgRepo.getWorkingDir(); | |
102 Path.Source pathSrc = new Path.SimpleSource(new PathRewrite.Composite(new RelativePathRewrite(repoRoot), hgRepo.getToRepoPathHelper())); | |
103 FileWalker w = new FileWalker(repoRoot, pathSrc); | |
104 int count = 0; | |
105 final long start = System.currentTimeMillis(); | |
106 while (w.hasNext()) { | |
107 count++; | |
108 w.next(); | |
109 } | |
110 System.out.printf("Traversal of %d files took %d ms", count, System.currentTimeMillis() - start); | |
92 } | 111 } |
93 | 112 |
94 /* | 113 /* |
95 * cpython repo with 70715 revisions. | 114 * cpython repo with 70715 revisions. |
96 3 revisions - 80 ms vs 250 ms (250ms init) | 115 3 revisions - 80 ms vs 250 ms (250ms init) |