Mercurial > hg4j
comparison cmdline/org/tmatesoft/hg/console/Main.java @ 367:2fadf8695f8a
Use 'revision index' instead of the vague 'local revision number' concept in the API
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 16 Dec 2011 15:37:27 +0100 |
parents | 189dc6dc1c3e |
children | ee8264d80747 d0e5dc3cae6e |
comparison
equal
deleted
inserted
replaced
366:189dc6dc1c3e | 367:2fadf8695f8a |
---|---|
224 /* | 224 /* |
225 * cpython repo with 70715 revisions. | 225 * cpython repo with 70715 revisions. |
226 3 revisions - 80 ms vs 250 ms (250ms init) | 226 3 revisions - 80 ms vs 250 ms (250ms init) |
227 4 revisions - 110 ms vs 265 ms (265 ms init) | 227 4 revisions - 110 ms vs 265 ms (265 ms init) |
228 5 revisions - 94 vs 266. | 228 5 revisions - 94 vs 266. |
229 complete iteration in changelog.getLocalRevision(tipNodeid) takes 47 ms | 229 complete iteration in changelog.getRevisionIndex(tipNodeid) takes 47 ms |
230 compared to complete iteration inside RevisionMap.init() of 171 ms. | 230 compared to complete iteration inside RevisionMap.init() of 171 ms. |
231 The only difference is latter instantiates Nodeids, while former compares binary content as is. | 231 The only difference is latter instantiates Nodeids, while former compares binary content as is. |
232 Hence, with 20-30 ms per regular getLocalRevision, it pays off to use RevisionMap with at least 15-20 | 232 Hence, with 20-30 ms per regular getLocalRevision, it pays off to use RevisionMap with at least 15-20 |
233 queries | 233 queries |
234 */ | 234 */ |
243 revs[2] = changelog.getRevision(tip / 2); | 243 revs[2] = changelog.getRevision(tip / 2); |
244 revs[1] = changelog.getRevision(tip / 4 + tip / 2); | 244 revs[1] = changelog.getRevision(tip / 4 + tip / 2); |
245 revs[0] = changelog.getRevision(tip); | 245 revs[0] = changelog.getRevision(tip); |
246 long start = System.currentTimeMillis(); | 246 long start = System.currentTimeMillis(); |
247 for (int i = 0; i < revs.length; i++) { | 247 for (int i = 0; i < revs.length; i++) { |
248 final int localRev = changelog.getLocalRevision(revs[i]); | 248 final int localRev = changelog.getRevisionIndex(revs[i]); |
249 System.out.printf("%d:%s\n", localRev, revs[i]); | 249 System.out.printf("%d:%s\n", localRev, revs[i]); |
250 } | 250 } |
251 System.out.println(System.currentTimeMillis() - start); | 251 System.out.println(System.currentTimeMillis() - start); |
252 System.out.println(); | 252 System.out.println(); |
253 // | 253 // |
254 start = System.currentTimeMillis(); | 254 start = System.currentTimeMillis(); |
255 rmap = changelog.new RevisionMap().init(); | 255 rmap = changelog.new RevisionMap().init(); |
256 long s2 = System.currentTimeMillis(); | 256 long s2 = System.currentTimeMillis(); |
257 for (int i = 0; i < revs.length; i++) { | 257 for (int i = 0; i < revs.length; i++) { |
258 final int localRev = rmap.localRevision(revs[i]); | 258 final int localRev = rmap.revisionIndex(revs[i]); |
259 System.out.printf("%d:%s\n", localRev, revs[i]); | 259 System.out.printf("%d:%s\n", localRev, revs[i]); |
260 } | 260 } |
261 System.out.println(System.currentTimeMillis() - start); | 261 System.out.println(System.currentTimeMillis() - start); |
262 System.out.printf("\t from that, init took %d ms\n", s2 - start); | 262 System.out.printf("\t from that, init took %d ms\n", s2 - start); |
263 | 263 |