Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestStatus.java @ 100:b71b3f7d24d4
Primitive performance test
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 28 Jan 2011 02:15:12 +0100 |
parents | 4d7bb95d553b |
children | 777ab7034c1b |
comparison
equal
deleted
inserted
replaced
99:4d7bb95d553b | 100:b71b3f7d24d4 |
---|---|
45 public static void main(String[] args) throws Exception { | 45 public static void main(String[] args) throws Exception { |
46 HgRepository repo = new HgLookup().detectFromWorkingDir(); | 46 HgRepository repo = new HgLookup().detectFromWorkingDir(); |
47 TestStatus test = new TestStatus(repo); | 47 TestStatus test = new TestStatus(repo); |
48 test.testLowLevel(); | 48 test.testLowLevel(); |
49 test.testStatusCommand(); | 49 test.testStatusCommand(); |
50 test.testPerformance(); | |
50 } | 51 } |
51 | 52 |
52 public TestStatus(HgRepository hgRepo) { | 53 public TestStatus(HgRepository hgRepo) { |
53 repo = hgRepo; | 54 repo = hgRepo; |
54 statusParser = new StatusOutputParser(); | 55 statusParser = new StatusOutputParser(); |
109 status --rev N when a file added past revision N was removed ((both physically and in dirstate), but not yet committed | 110 status --rev N when a file added past revision N was removed ((both physically and in dirstate), but not yet committed |
110 | 111 |
111 Reports extra REMOVED file (the one added and removed in between). Shall not | 112 Reports extra REMOVED file (the one added and removed in between). Shall not |
112 */ | 113 */ |
113 } | 114 } |
115 | |
116 /* | |
117 * With warm-up of previous tests, 10 runs, time in milliseconds | |
118 * 'hg status -A': Native client total 953 (95 per run), Java client 94 (9) | |
119 * 'hg status -A --rev 3:80': Native client total 1828 (182 per run), Java client 235 (23) | |
120 * 'hg log --debug', 10 runs: Native client total 1766 (176 per run), Java client 78 (7) | |
121 */ | |
122 public void testPerformance() throws Exception { | |
123 final int runs = 10; | |
124 final long start1 = System.currentTimeMillis(); | |
125 for (int i = 0; i < runs; i++) { | |
126 statusParser.reset(); | |
127 eh.run("hg", "status", "-A", "--rev", "3:80"); | |
128 } | |
129 final long start2 = System.currentTimeMillis(); | |
130 for (int i = 0; i < runs; i++) { | |
131 HgStatusCollector.Record r = new HgStatusCollector.Record(); | |
132 new StatusCommand(repo).all().base(3).revision(80).execute(r); | |
133 } | |
134 final long end = System.currentTimeMillis(); | |
135 System.out.printf("'hg status -A --rev 3:80', %d runs: Native client total %d (%d per run), Java client %d (%d)\n", runs, start2-start1, (start2-start1)/runs, end-start2, (end-start2)/runs); | |
136 } | |
137 | |
114 | 138 |
115 private static void report(String what, HgStatusCollector.Record r, StatusOutputParser statusParser) { | 139 private static void report(String what, HgStatusCollector.Record r, StatusOutputParser statusParser) { |
116 System.out.println(">>>" + what); | 140 System.out.println(">>>" + what); |
117 reportNotEqual("MODIFIED", r.getModified(), statusParser.getModified()); | 141 reportNotEqual("MODIFIED", r.getModified(), statusParser.getModified()); |
118 reportNotEqual("ADDED", r.getAdded(), statusParser.getAdded()); | 142 reportNotEqual("ADDED", r.getAdded(), statusParser.getAdded()); |