# Copyright 2018-2019 Florian Fischer # # This file is part of allocbench. # # allocbench is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # allocbench is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with allocbench. If not, see . """Definition of the httpd benchmark""" import re from src.benchmark import Benchmark import src.facter import src.plots as plt class BenchmarkHTTPD(Benchmark): """TODO""" def __init__(self): name = "httpd" self.args = { "nthreads": Benchmark.scale_threads_for_cpus(2), "site": ["index.html", "index.php"] } self.cmd = "ab -n 10000 -c {nthreads} localhost:8080/{site}" self.measure_cmd = "" self.servers = [{"name": "nginx", "cmd": "nginx -c {builddir}/benchmarks/httpd/etc/nginx/nginx.conf"}, {"name": "php-fpm", "cmd": "php-fpm -c {builddir}/benchmarks/httpd/etc/php/php.ini "\ "-y {builddir}/benchmarks/httpd/etc/php/php-fpm.conf -F"}] self.requirements = ["nginx", "ab"] super().__init__(name) def prepare(self): super().prepare() self.results["facts"]["versions"]["nginx"] = src.facter.exe_version( "nginx", "-v") self.results["facts"]["versions"]["ab"] = src.facter.exe_version( "ab", "-V") @staticmethod def process_output(result, stdout, stderr, allocator, perm): result["time"] = re.search( "Time taken for tests:\\s*(\\d*\\.\\d*) seconds", stdout).group(1) result["requests"] = re.search( "Requests per second:\\s*(\\d*\\.\\d*) .*", stdout).group(1) def summary(self): plt.plot_fixed_arg(self, "{requests}", xlabel="threads", ylabel="requests/s", autoticks=False, file_postfix="requests", title="{perm.site}: requests/s") plt.plot_fixed_arg(self, "{nginx_vmhwm}", xlabel="threads", ylabel="VmHWM in KB", title="{perm.site}: nginx memory usage", file_postfix="httpd_vmhwm", autoticks=False) plt.plot_fixed_arg(self, "{php-fpm_vmhwm}", xlabel="threads", ylabel="VmHWM in KB", title="{perm.site}: php-fpm memory usage", file_postfix="php-fpm_vmhwm", autoticks=False) httpd = BenchmarkHTTPD()