1029 for i in xrange(threads): |
1029 for i in xrange(threads): |
1030 q.put(None) |
1030 q.put(None) |
1031 with ready: |
1031 with ready: |
1032 ready.notify_all() |
1032 ready.notify_all() |
1033 |
1033 |
|
1034 @command('perfunidiff', revlogopts + formatteropts + [ |
|
1035 ('', 'count', 1, 'number of revisions to test (when using --startrev)'), |
|
1036 ('', 'alldata', False, 'test unidiffs for all associated revisions'), |
|
1037 ], '-c|-m|FILE REV') |
|
1038 def perfunidiff(ui, repo, file_, rev=None, count=None, **opts): |
|
1039 """benchmark a unified diff between revisions |
|
1040 |
|
1041 This doesn't include any copy tracing - it's just a unified diff |
|
1042 of the texts. |
|
1043 |
|
1044 By default, benchmark a diff between its delta parent and itself. |
|
1045 |
|
1046 With ``--count``, benchmark diffs between delta parents and self for N |
|
1047 revisions starting at the specified revision. |
|
1048 |
|
1049 With ``--alldata``, assume the requested revision is a changeset and |
|
1050 measure diffs for all changes related to that changeset (manifest |
|
1051 and filelogs). |
|
1052 """ |
|
1053 if opts['alldata']: |
|
1054 opts['changelog'] = True |
|
1055 |
|
1056 if opts.get('changelog') or opts.get('manifest'): |
|
1057 file_, rev = None, file_ |
|
1058 elif rev is None: |
|
1059 raise error.CommandError('perfunidiff', 'invalid arguments') |
|
1060 |
|
1061 textpairs = [] |
|
1062 |
|
1063 r = cmdutil.openrevlog(repo, 'perfunidiff', file_, opts) |
|
1064 |
|
1065 startrev = r.rev(r.lookup(rev)) |
|
1066 for rev in range(startrev, min(startrev + count, len(r) - 1)): |
|
1067 if opts['alldata']: |
|
1068 # Load revisions associated with changeset. |
|
1069 ctx = repo[rev] |
|
1070 mtext = repo.manifestlog._revlog.revision(ctx.manifestnode()) |
|
1071 for pctx in ctx.parents(): |
|
1072 pman = repo.manifestlog._revlog.revision(pctx.manifestnode()) |
|
1073 textpairs.append((pman, mtext)) |
|
1074 |
|
1075 # Load filelog revisions by iterating manifest delta. |
|
1076 man = ctx.manifest() |
|
1077 pman = ctx.p1().manifest() |
|
1078 for filename, change in pman.diff(man).items(): |
|
1079 fctx = repo.file(filename) |
|
1080 f1 = fctx.revision(change[0][0] or -1) |
|
1081 f2 = fctx.revision(change[1][0] or -1) |
|
1082 textpairs.append((f1, f2)) |
|
1083 else: |
|
1084 dp = r.deltaparent(rev) |
|
1085 textpairs.append((r.revision(dp), r.revision(rev))) |
|
1086 |
|
1087 def d(): |
|
1088 for left, right in textpairs: |
|
1089 # The date strings don't matter, so we pass empty strings. |
|
1090 headerlines, hunks = mdiff.unidiff( |
|
1091 left, '', right, '', 'left', 'right') |
|
1092 # consume iterators in roughly the way patch.py does |
|
1093 b'\n'.join(headerlines) |
|
1094 b''.join(sum((list(hlines) for hrange, hlines in hunks), [])) |
|
1095 timer, fm = gettimer(ui, opts) |
|
1096 timer(d) |
|
1097 fm.end() |
|
1098 |
1034 @command('perfdiffwd', formatteropts) |
1099 @command('perfdiffwd', formatteropts) |
1035 def perfdiffwd(ui, repo, **opts): |
1100 def perfdiffwd(ui, repo, **opts): |
1036 """Profile diff of working directory changes""" |
1101 """Profile diff of working directory changes""" |
1037 timer, fm = gettimer(ui, opts) |
1102 timer, fm = gettimer(ui, opts) |
1038 options = { |
1103 options = { |