Skip to content

Commit b5b3315

Browse files
committed
use artefacts from environment variable for benchmarks where available
1 parent 0409e59 commit b5b3315

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

mx.graalpython/mx_graalpython_python_benchmarks.py

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,17 @@ def _vmRun(self, vm, workdir, command, benchmarks, bmSuiteArgs):
344344

345345
if not hasattr(self, "prepared"):
346346
self.prepared = True
347-
mx.run(
348-
["hg", "clone", "https://foss.heptapod.net/pypy/benchmarks"],
349-
cwd=workdir,
350-
)
351-
mx.run(["hg", "up", "-C", self.VERSION], cwd=join(workdir, "benchmarks"))
347+
if artifact := os.environ.get("PYPY_BENCHMARKS_DIR"):
348+
shutil.copytree(artifact, join(workdir, "benchmarks"))
349+
else:
350+
mx.warn("PYPY_BENCHMARKS_DIR is not set, cloning repository")
351+
mx.run(
352+
["hg", "clone", "https://foss.heptapod.net/pypy/benchmarks"],
353+
cwd=workdir,
354+
)
355+
mx.run(
356+
["hg", "up", "-C", self.VERSION], cwd=join(workdir, "benchmarks")
357+
)
352358

353359
# workaround for pypy's benchmarks script issue
354360
with open(join(workdir, "benchmarks", "nullpython.py")) as f:
@@ -412,25 +418,28 @@ def _vmRun(self, vm, workdir, command, benchmarks, bmSuiteArgs):
412418

413419
if not hasattr(self, "prepared"):
414420
self.prepared = True
415-
mx.run(
416-
[
417-
"git",
418-
"clone",
419-
"--depth",
420-
"1",
421-
"https://github.com/numpy/numpy.git",
422-
"--branch",
423-
self.VERSION,
424-
"--single-branch",
425-
],
426-
cwd=workdir,
427-
)
428-
mx.run(
429-
["git", "branch", "main"], cwd=join(workdir, "numpy")
430-
) # workaround for asv, which expects a main branch
431-
mx.run(
432-
["git", "branch", "master"], cwd=join(workdir, "numpy")
433-
) # workaround for asv, which expects some branches
421+
npdir = join(workdir, "numpy")
422+
if artifact := os.environ.get("NUMPY_BENCHMARKS_DIR"):
423+
shutil.copytree(artifact, npdir)
424+
mx.run(["git", "init", "."], cwd=npdir, nonZeroIsFatal=False)
425+
mx.run(["git", "branch", self.VERSION], cwd=npdir, nonZeroIsFatal=False)
426+
else:
427+
mx.warn("NUMPY_BENCHMARKS_DIR is not set, cloning numpy repository")
428+
mx.run(
429+
[
430+
"git",
431+
"clone",
432+
"--depth",
433+
"1",
434+
"https://github.com/numpy/numpy.git",
435+
"--branch",
436+
self.VERSION,
437+
"--single-branch",
438+
],
439+
cwd=workdir,
440+
)
441+
mx.run(["git", "branch", "main"], cwd=npdir, nonZeroIsFatal=False)
442+
mx.run(["git", "branch", "master"], cwd=npdir, nonZeroIsFatal=False)
434443

435444
vm.run(workdir, ["-m", "venv", vm_venv])
436445
mx.run(

0 commit comments

Comments
 (0)