##// END OF EJS Templates
perf: add a perf::stream-consume...
marmoute -
r51571:45968123 default
parent child Browse files
Show More
@@ -2024,6 +2024,85 b' def perf_stream_clone_generate(ui, repo,'
2024 fm.end()
2024 fm.end()
2025
2025
2026
2026
2027 @command(
2028 b'perf::stream-consume',
2029 formatteropts,
2030 )
2031 def perf_stream_clone_consume(ui, repo, filename, **opts):
2032 """benchmark the full application of a stream clone
2033
2034 This include the creation of the repository
2035 """
2036 # try except to appease check code
2037 msg = b"mercurial too old, missing necessary module: %s"
2038 try:
2039 from mercurial import bundle2
2040 except ImportError as exc:
2041 msg %= _bytestr(exc)
2042 raise error.Abort(msg)
2043 try:
2044 from mercurial import exchange
2045 except ImportError as exc:
2046 msg %= _bytestr(exc)
2047 raise error.Abort(msg)
2048 try:
2049 from mercurial import hg
2050 except ImportError as exc:
2051 msg %= _bytestr(exc)
2052 raise error.Abort(msg)
2053 try:
2054 from mercurial import localrepo
2055 except ImportError as exc:
2056 msg %= _bytestr(exc)
2057 raise error.Abort(msg)
2058
2059 opts = _byteskwargs(opts)
2060 timer, fm = gettimer(ui, opts)
2061
2062 # deletion of the generator may trigger some cleanup that we do not want to
2063 # measure
2064 if not (os.path.isfile(filename) and os.access(filename, os.R_OK)):
2065 raise error.Abort("not a readable file: %s" % filename)
2066
2067 run_variables = [None, None]
2068
2069 @contextlib.contextmanager
2070 def context():
2071 with open(filename, mode='rb') as bundle:
2072 with tempfile.TemporaryDirectory() as tmp_dir:
2073 tmp_dir = fsencode(tmp_dir)
2074 run_variables[0] = bundle
2075 run_variables[1] = tmp_dir
2076 yield
2077 run_variables[0] = None
2078 run_variables[1] = None
2079
2080 def runone():
2081 bundle = run_variables[0]
2082 tmp_dir = run_variables[1]
2083 # only pass ui when no srcrepo
2084 localrepo.createrepository(
2085 repo.ui, tmp_dir, requirements=repo.requirements
2086 )
2087 target = hg.repository(repo.ui, tmp_dir)
2088 gen = exchange.readbundle(target.ui, bundle, bundle.name)
2089 # stream v1
2090 if util.safehasattr(gen, 'apply'):
2091 gen.apply(target)
2092 else:
2093 with target.transaction(b"perf::stream-consume") as tr:
2094 bundle2.applybundle(
2095 target,
2096 gen,
2097 tr,
2098 source=b'unbundle',
2099 url=filename,
2100 )
2101
2102 timer(runone, context=context, title=b"consume")
2103 fm.end()
2104
2105
2027 @command(b'perf::parents|perfparents', formatteropts)
2106 @command(b'perf::parents|perfparents', formatteropts)
2028 def perfparents(ui, repo, **opts):
2107 def perfparents(ui, repo, **opts):
2029 """benchmark the time necessary to fetch one changeset's parents.
2108 """benchmark the time necessary to fetch one changeset's parents.
@@ -188,6 +188,8 b' perfstatus'
188 perf::startup
188 perf::startup
189 (no help text available)
189 (no help text available)
190 perf::status benchmark the performance of a single status call
190 perf::status benchmark the performance of a single status call
191 perf::stream-consume
192 benchmark the full application of a stream clone
191 perf::stream-generate
193 perf::stream-generate
192 benchmark the full generation of a stream clone
194 benchmark the full generation of a stream clone
193 perf::stream-locked-section
195 perf::stream-locked-section
General Comments 0
You need to be logged in to leave comments. Login now