1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de>
#
# 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 <http://www.gnu.org/licenses/>.
"""Definition of the httpd benchmark"""
import re
from src.benchmark import Benchmark
import src.facter
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):
allocators = self.results["allocators"]
self.plot_fixed_arg("{requests}",
xlabel='"threads"',
ylabel='"requests/s"',
autoticks=False,
filepostfix="requests",
title='perm.site + ": requests/s"')
self.plot_fixed_arg("{nginx_vmhwm}",
xlabel='"threads"',
ylabel='"VmHWM in KB"',
title='perm.site + ": nginx memory usage"',
filepostfix="httpd_vmhwm",
autoticks=False)
self.plot_fixed_arg("{php-fpm_vmhwm}",
xlabel='"threads"',
ylabel='"VmHWM in KB"',
title='perm.site + ": php-fpm memory usage"',
filepostfix="php-fpm_vmhwm",
autoticks=False)
httpd = BenchmarkHTTPD()
|