Show More
@@ -25,7 +25,9 b' import os' | |||
|
25 | 25 | import random |
|
26 | 26 | import struct |
|
27 | 27 | import sys |
|
28 | import threading | |
|
28 | 29 | import time |
|
30 | import util.queue | |
|
29 | 31 | from mercurial import ( |
|
30 | 32 | changegroup, |
|
31 | 33 | cmdutil, |
@@ -933,11 +935,25 b' def perffncacheencode(ui, repo, **opts):' | |||
|
933 | 935 | timer(d) |
|
934 | 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 | 949 | @command('perfbdiff', revlogopts + formatteropts + [ |
|
937 | 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 | 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 | 957 | """benchmark a bdiff between revisions |
|
942 | 958 | |
|
943 | 959 | By default, benchmark a bdiff between its delta parent and itself. |
@@ -983,14 +999,39 b' def perfbdiff(ui, repo, file_, rev=None,' | |||
|
983 | 999 | dp = r.deltaparent(rev) |
|
984 | 1000 | textpairs.append((r.revision(dp), r.revision(rev))) |
|
985 | 1001 | |
|
1002 | withthreads = threads > 0 | |
|
1003 | if not withthreads: | |
|
986 | 1004 | def d(): |
|
987 | 1005 | for pair in textpairs: |
|
988 | 1006 | mdiff.textdiff(*pair) |
|
989 | ||
|
1007 | else: | |
|
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() | |
|
990 | 1024 | timer, fm = gettimer(ui, opts) |
|
991 | 1025 | timer(d) |
|
992 | 1026 | fm.end() |
|
993 | 1027 | |
|
1028 | if withthreads: | |
|
1029 | done.set() | |
|
1030 | for i in xrange(threads): | |
|
1031 | q.put(None) | |
|
1032 | with ready: | |
|
1033 | ready.notify_all() | |
|
1034 | ||
|
994 | 1035 | @command('perfdiffwd', formatteropts) |
|
995 | 1036 | def perfdiffwd(ui, repo, **opts): |
|
996 | 1037 | """Profile diff of working directory changes""" |
@@ -175,7 +175,7 b' Check perf.py for historical portability' | |||
|
175 | 175 | $ (testrepohg files -r 1.2 glob:mercurial/*.c glob:mercurial/*.py; |
|
176 | 176 | > testrepohg files -r tip glob:mercurial/*.c glob:mercurial/*.py) | |
|
177 | 177 | > "$TESTDIR"/check-perf-code.py contrib/perf.py |
|
178 |
contrib/perf.py: |
|
|
178 | contrib/perf.py:\d+: (re) | |
|
179 | 179 | > from mercurial import ( |
|
180 | 180 | import newer module separately in try clause for early Mercurial |
|
181 | 181 | [1] |
General Comments 0
You need to be logged in to leave comments.
Login now