931 for p in s.fncache.entries: |
933 for p in s.fncache.entries: |
932 s.encode(p) |
934 s.encode(p) |
933 timer(d) |
935 timer(d) |
934 fm.end() |
936 fm.end() |
935 |
937 |
|
938 def _bdiffworker(q, ready, done): |
|
939 while not done.is_set(): |
|
940 pair = q.get() |
|
941 while pair is not None: |
|
942 mdiff.textdiff(*pair) |
|
943 q.task_done() |
|
944 pair = q.get() |
|
945 q.task_done() # for the None one |
|
946 with ready: |
|
947 ready.wait() |
|
948 |
936 @command('perfbdiff', revlogopts + formatteropts + [ |
949 @command('perfbdiff', revlogopts + formatteropts + [ |
937 ('', 'count', 1, 'number of revisions to test (when using --startrev)'), |
950 ('', 'count', 1, 'number of revisions to test (when using --startrev)'), |
938 ('', 'alldata', False, 'test bdiffs for all associated revisions')], |
951 ('', 'alldata', False, 'test bdiffs for all associated revisions'), |
|
952 ('', 'threads', 0, 'number of thread to use (disable with 0)'), |
|
953 ], |
|
954 |
939 '-c|-m|FILE REV') |
955 '-c|-m|FILE REV') |
940 def perfbdiff(ui, repo, file_, rev=None, count=None, **opts): |
956 def perfbdiff(ui, repo, file_, rev=None, count=None, threads=0, **opts): |
941 """benchmark a bdiff between revisions |
957 """benchmark a bdiff between revisions |
942 |
958 |
943 By default, benchmark a bdiff between its delta parent and itself. |
959 By default, benchmark a bdiff between its delta parent and itself. |
944 |
960 |
945 With ``--count``, benchmark bdiffs between delta parents and self for N |
961 With ``--count``, benchmark bdiffs between delta parents and self for N |
981 textpairs.append((f1, f2)) |
997 textpairs.append((f1, f2)) |
982 else: |
998 else: |
983 dp = r.deltaparent(rev) |
999 dp = r.deltaparent(rev) |
984 textpairs.append((r.revision(dp), r.revision(rev))) |
1000 textpairs.append((r.revision(dp), r.revision(rev))) |
985 |
1001 |
986 def d(): |
1002 withthreads = threads > 0 |
987 for pair in textpairs: |
1003 if not withthreads: |
988 mdiff.textdiff(*pair) |
1004 def d(): |
989 |
1005 for pair in textpairs: |
990 timer, fm = gettimer(ui, opts) |
1006 mdiff.textdiff(*pair) |
991 timer(d) |
1007 else: |
992 fm.end() |
1008 q = util.queue() |
|
1009 for i in xrange(threads): |
|
1010 q.put(None) |
|
1011 ready = threading.Condition() |
|
1012 done = threading.Event() |
|
1013 for i in xrange(threads): |
|
1014 threading.Thread(target=_bdiffworker, args=(q, ready, done)).start() |
|
1015 q.join() |
|
1016 def d(): |
|
1017 for pair in textpairs: |
|
1018 q.put(pair) |
|
1019 for i in xrange(threads): |
|
1020 q.put(None) |
|
1021 with ready: |
|
1022 ready.notify_all() |
|
1023 q.join() |
|
1024 timer, fm = gettimer(ui, opts) |
|
1025 timer(d) |
|
1026 fm.end() |
|
1027 |
|
1028 if withthreads: |
|
1029 done.set() |
|
1030 for i in xrange(threads): |
|
1031 q.put(None) |
|
1032 with ready: |
|
1033 ready.notify_all() |
993 |
1034 |
994 @command('perfdiffwd', formatteropts) |
1035 @command('perfdiffwd', formatteropts) |
995 def perfdiffwd(ui, repo, **opts): |
1036 def perfdiffwd(ui, repo, **opts): |
996 """Profile diff of working directory changes""" |
1037 """Profile diff of working directory changes""" |
997 timer, fm = gettimer(ui, opts) |
1038 timer, fm = gettimer(ui, opts) |