Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestHistory.java @ 100:b71b3f7d24d4
Primitive performance test
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 28 Jan 2011 02:15:12 +0100 |
parents | bcd31a4c638a |
children | 777ab7034c1b |
comparison
equal
deleted
inserted
replaced
99:4d7bb95d553b | 100:b71b3f7d24d4 |
---|---|
20 import java.util.Iterator; | 20 import java.util.Iterator; |
21 import java.util.List; | 21 import java.util.List; |
22 | 22 |
23 import org.tmatesoft.hg.core.Cset; | 23 import org.tmatesoft.hg.core.Cset; |
24 import org.tmatesoft.hg.core.LogCommand; | 24 import org.tmatesoft.hg.core.LogCommand; |
25 import org.tmatesoft.hg.core.StatusCommand; | |
25 import org.tmatesoft.hg.core.LogCommand.CollectHandler; | 26 import org.tmatesoft.hg.core.LogCommand.CollectHandler; |
26 import org.tmatesoft.hg.core.LogCommand.FileHistoryHandler; | 27 import org.tmatesoft.hg.core.LogCommand.FileHistoryHandler; |
27 import org.tmatesoft.hg.core.LogCommand.FileRevision; | 28 import org.tmatesoft.hg.core.LogCommand.FileRevision; |
28 import org.tmatesoft.hg.core.Path; | 29 import org.tmatesoft.hg.core.Path; |
29 import org.tmatesoft.hg.repo.HgRepository; | 30 import org.tmatesoft.hg.repo.HgRepository; |
30 import org.tmatesoft.hg.repo.HgLookup; | 31 import org.tmatesoft.hg.repo.HgLookup; |
32 import org.tmatesoft.hg.repo.HgStatusCollector; | |
31 import org.tmatesoft.hg.test.LogOutputParser.Record; | 33 import org.tmatesoft.hg.test.LogOutputParser.Record; |
32 | 34 |
33 | 35 |
34 /** | 36 /** |
35 * | 37 * |
44 | 46 |
45 public static void main(String[] args) throws Exception { | 47 public static void main(String[] args) throws Exception { |
46 TestHistory th = new TestHistory(new HgLookup().detectFromWorkingDir()); | 48 TestHistory th = new TestHistory(new HgLookup().detectFromWorkingDir()); |
47 th.testCompleteLog(); | 49 th.testCompleteLog(); |
48 th.testFollowHistory(); | 50 th.testFollowHistory(); |
51 th.testPerformance(); | |
49 } | 52 } |
50 | 53 |
51 public TestHistory(HgRepository hgRepo) { | 54 public TestHistory(HgRepository hgRepo) { |
52 repo = hgRepo; | 55 repo = hgRepo; |
53 eh = new ExecHelper(changelogParser = new LogOutputParser(true), null); | 56 eh = new ExecHelper(changelogParser = new LogOutputParser(true), null); |
110 System.out.println("Insufficient results from Java"); | 113 System.out.println("Insufficient results from Java"); |
111 hasErrors = true; | 114 hasErrors = true; |
112 } | 115 } |
113 System.out.println(what + (hasErrors ? " FAIL" : " OK")); | 116 System.out.println(what + (hasErrors ? " FAIL" : " OK")); |
114 } | 117 } |
118 | |
119 public void testPerformance() throws Exception { | |
120 final int runs = 10; | |
121 final long start1 = System.currentTimeMillis(); | |
122 for (int i = 0; i < runs; i++) { | |
123 changelogParser.reset(); | |
124 eh.run("hg", "log", "--debug"); | |
125 } | |
126 final long start2 = System.currentTimeMillis(); | |
127 for (int i = 0; i < runs; i++) { | |
128 new LogCommand(repo).execute(); | |
129 } | |
130 final long end = System.currentTimeMillis(); | |
131 System.out.printf("'hg log --debug', %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); | |
132 } | |
115 } | 133 } |