From 84eec0baba49bff0a5c2b64834bc2d75d687e7b5 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 21 Sep 2019 14:04:26 +0200 Subject: add artifacts Artifacts are downloadable external ressources. They provide their ressource (vcs commit, extracted archive) using Artifact.provide. GitArtifact download a bare git repository and provides specific commits using worktrees. Use GitArtifact for the linux kernel source --- src/benchmarks/fd.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/benchmarks/fd.py') diff --git a/src/benchmarks/fd.py b/src/benchmarks/fd.py index d78988a..55fe3af 100644 --- a/src/benchmarks/fd.py +++ b/src/benchmarks/fd.py @@ -23,10 +23,15 @@ import subprocess import sys from urllib.request import urlretrieve +from src.artifact import GitArtifact from src.benchmark import Benchmark from src.util import print_info, download_reporthook +LINUX_ARTIFACT = GitArtifact("linux", "git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git") +LINUX_VERSION = "v5.3" + + class BenchmarkFd(Benchmark): """fd benchmark """ @@ -36,7 +41,7 @@ class BenchmarkFd(Benchmark): super().__init__(name) - self.cmd = "fd -HI -e c \"\" {build_dir}/linux" + self.cmd = "fd -HI -e c '.*[0-9].*' {build_dir}/linux" def prepare(self): super().prepare() @@ -75,15 +80,8 @@ class BenchmarkFd(Benchmark): dest = os.path.join(self.build_dir, exe) os.link(src, dest) - linux_version = "v5.3" - linux_url = f"git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git" - linux_dir = os.path.join(self.build_dir, "linux") - if not os.path.isdir(linux_dir): - # Extract redis - proc = subprocess.run(["git", "clone", linux_url, linux_dir], - # stdout=subprocess.PIPE, stderr=subprocess.PIPE, - universal_newlines=True) + LINUX_ARTIFACT.provide(LINUX_VERSION, os.path.join(self.build_dir, "linux")) def summary(self): self.barplot_single_arg("{task-clock}", -- cgit v1.2.3 From 6e019b83c2f82552704feb4d8ce18e0d3a19d75a Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 23 Sep 2019 13:42:05 +0200 Subject: use ArchiveArtifacts for all benchmark resources --- src/benchmarks/fd.py | 61 +++++++++++++++++----------------------------------- 1 file changed, 20 insertions(+), 41 deletions(-) (limited to 'src/benchmarks/fd.py') diff --git a/src/benchmarks/fd.py b/src/benchmarks/fd.py index 55fe3af..e133e1c 100644 --- a/src/benchmarks/fd.py +++ b/src/benchmarks/fd.py @@ -23,13 +23,9 @@ import subprocess import sys from urllib.request import urlretrieve -from src.artifact import GitArtifact +from src.artifact import ArchiveArtifact, GitArtifact from src.benchmark import Benchmark -from src.util import print_info, download_reporthook - - -LINUX_ARTIFACT = GitArtifact("linux", "git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git") -LINUX_VERSION = "v5.3" +from src.util import print_info class BenchmarkFd(Benchmark): @@ -38,7 +34,6 @@ class BenchmarkFd(Benchmark): def __init__(self): name = "fd" - super().__init__(name) self.cmd = "fd -HI -e c '.*[0-9].*' {build_dir}/linux" @@ -46,42 +41,26 @@ class BenchmarkFd(Benchmark): def prepare(self): super().prepare() - fd_tag = "v7.4.0" - fd_release = f"fd-{fd_tag}-x86_64-unknown-linux-gnu" - fd_archive = f"{fd_release}.tar.gz" - fd_url = f"https://github.com/sharkdp/fd/releases/latest/download/{fd_archive}" - fd_dir = os.path.join(self.build_dir, fd_release) - - self.results["facts"]["versions"]["fd"] = fd_tag - - # Create builddir - os.makedirs(self.build_dir, exist_ok=True) - - if not os.path.isdir(fd_dir): - if not os.path.isfile(fd_archive): - print(f"Downloading fd {fd_tag}...") - urlretrieve(fd_url, fd_archive, download_reporthook) - sys.stderr.write("\n") - - - # Extract redis - proc = subprocess.run(["tar", "Cxf", self.build_dir, fd_archive], - # stdout=subprocess.PIPE, stderr=subprocess.PIPE, - universal_newlines=True) - - # delete archive - if proc.returncode == 0: - os.remove(fd_archive) - - - # create symlinks - for exe in ["fd"]: - src = os.path.join(fd_dir, exe) - dest = os.path.join(self.build_dir, exe) - os.link(src, dest) + fd_version = "v7.4.0" + self.results["facts"]["versions"]["fd"] = fd_version + fd_url = ("https://github.com/sharkdp/fd/releases/latest/download/" + f"fd-{fd_version}-x86_64-unknown-linux-gnu.tar.gz") + + fd = ArchiveArtifact("fd", fd_url, "tar", "a5d8e7c8484449aa324a46abfdfaf026d7de77ee") + + fd_dir = os.path.join(self.build_dir, "fd_sources") + fd.provide(fd_dir) + + # create symlinks + for exe in ["fd"]: + src = os.path.join(fd_dir, f"fd-{fd_version}-x86_64-unknown-linux-gnu", exe) + dest = os.path.join(self.build_dir, exe) + os.link(src, dest) - LINUX_ARTIFACT.provide(LINUX_VERSION, os.path.join(self.build_dir, "linux")) + linux = GitArtifact("linux", "git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git") + linux_version = "v5.3" + linux.provide(linux_version, os.path.join(self.build_dir, "linux")) def summary(self): self.barplot_single_arg("{task-clock}", -- cgit v1.2.3 From 3f43d0f464b8da5829ff652a3208720c74d1882b Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 23 Sep 2019 13:51:40 +0200 Subject: don't prepare fd if it was already prepared --- src/benchmarks/fd.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/benchmarks/fd.py') diff --git a/src/benchmarks/fd.py b/src/benchmarks/fd.py index e133e1c..21a987d 100644 --- a/src/benchmarks/fd.py +++ b/src/benchmarks/fd.py @@ -41,6 +41,9 @@ class BenchmarkFd(Benchmark): def prepare(self): super().prepare() + if os.path.exists(self.build_dir): + return + fd_version = "v7.4.0" self.results["facts"]["versions"]["fd"] = fd_version fd_url = ("https://github.com/sharkdp/fd/releases/latest/download/" -- cgit v1.2.3