comparison contrib/perf.py @ 51560:8e8776a28683

perf: create the temporary target next to the source in stream-consume See inline comment for rational.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 03 Apr 2024 15:33:25 +0200
parents f1512dbfee9f
children 90ef3e042e10
comparison
equal deleted inserted replaced
51558:c4aab3661f25 51560:8e8776a28683
2186 if not (os.path.isfile(filename) and os.access(filename, os.R_OK)): 2186 if not (os.path.isfile(filename) and os.access(filename, os.R_OK)):
2187 raise error.Abort("not a readable file: %s" % filename) 2187 raise error.Abort("not a readable file: %s" % filename)
2188 2188
2189 run_variables = [None, None] 2189 run_variables = [None, None]
2190 2190
2191 # we create the new repository next to the other one for two reasons:
2192 # - this way we use the same file system, which are relevant for benchmark
2193 # - if /tmp/ is small, the operation could overfills it.
2194 source_repo_dir = os.path.dirname(repo.root)
2195
2191 @contextlib.contextmanager 2196 @contextlib.contextmanager
2192 def context(): 2197 def context():
2193 with open(filename, mode='rb') as bundle: 2198 with open(filename, mode='rb') as bundle:
2194 with tempfile.TemporaryDirectory() as tmp_dir: 2199 with tempfile.TemporaryDirectory(
2200 prefix=b'hg-perf-stream-consume-',
2201 dir=source_repo_dir,
2202 ) as tmp_dir:
2195 tmp_dir = fsencode(tmp_dir) 2203 tmp_dir = fsencode(tmp_dir)
2196 run_variables[0] = bundle 2204 run_variables[0] = bundle
2197 run_variables[1] = tmp_dir 2205 run_variables[1] = tmp_dir
2198 yield 2206 yield
2199 run_variables[0] = None 2207 run_variables[0] = None