aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/benchmarks/redis.py52
-rw-r--r--src/benchmarks/redis/Makefile20
2 files changed, 52 insertions, 20 deletions
diff --git a/src/benchmarks/redis.py b/src/benchmarks/redis.py
index 945d3a0..689a9b6 100644
--- a/src/benchmarks/redis.py
+++ b/src/benchmarks/redis.py
@@ -17,13 +17,19 @@
"""Definition of the redis benchmark"""
+import os
import re
+import subprocess
+import sys
+from urllib.request import urlretrieve
from src.benchmark import Benchmark
+from src.util import print_info, download_reporthook
REQUESTS_RE = re.compile("(?P<requests>(\\d*.\\d*)) requests per second")
+
class BenchmarkRedis(Benchmark):
"""Redis benchmark
@@ -41,6 +47,52 @@ class BenchmarkRedis(Benchmark):
super().__init__(name)
+ def prepare(self):
+ super().prepare()
+
+ redis_version = "5.0.5"
+ redis_archive = f"redis-{redis_version}.tar.gz"
+ redis_url = f"http://download.redis.io/releases/{redis_archive}"
+ redis_dir = os.path.join(self.build_dir, f"redis-{redis_version}")
+
+ if not os.path.isdir(redis_dir):
+ if not os.path.isfile(redis_archive):
+ print(f"Downloading redis-{redis_version}...")
+ urlretrieve(redis_url, redis_archive, download_reporthook)
+ sys.stderr.write("\n")
+
+ # Create build_dir
+ os.mkdir(self.build_dir)
+
+ # Extract redis
+ proc = subprocess.run(["tar", "Cxf", self.build_dir, redis_archive],
+ # stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ universal_newlines=True)
+
+ # delete archive
+ if proc.returncode == 0:
+ os.remove(redis_archive)
+ else:
+ return False
+
+ # building redis
+ proc = subprocess.run(["make", "-C", redis_dir],
+ # stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ universal_newlines=True)
+
+ if proc.returncode != 0:
+ return False
+
+
+ # create symlinks
+ for exe in ["redis-cli", "redis-server", "redis-benchmark"]:
+ src = os.path.join(redis_dir, "src", exe)
+ dest = os.path.join(self.build_dir, exe)
+ os.link(src, dest)
+
+ return True
+
+
@staticmethod
def process_output(result, stdout, stderr, allocator, perm):
result["requests"] = REQUESTS_RE.search(stdout).group("requests")
diff --git a/src/benchmarks/redis/Makefile b/src/benchmarks/redis/Makefile
deleted file mode 100644
index de72342..0000000
--- a/src/benchmarks/redis/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-OBJDIR ?= obj
-
-unexport CC
-unexport CXX
-unexport WARNFLAGS
-unexport COMMONFLAGS
-unexport OPTFLAGS
-unexport CFLAGS
-unexport CXXFLAGS
-unexport LDFLAGS
-unexport LDXXFLAGS
-
-.PHONY = all clean
-
-all:
- @echo building redis benchmark
- ./build.sh $(OBJDIR) $(REDIS_VERSION)
-
-clean:
- rm -rf $(OBJDIR)