From fd7e02471dd5e3dd1b37f053a130ae29f0cfdb6d Mon Sep 17 00:00:00 2001 From: Jacky_Yin Date: Sun, 12 Sep 2021 13:15:41 +0800 Subject: [PATCH 1/3] fix: synxtax and path for benchmark.py --- src/scripts/benchmark.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/scripts/benchmark.py b/src/scripts/benchmark.py index ce25642ef..05a69e5e8 100755 --- a/src/scripts/benchmark.py +++ b/src/scripts/benchmark.py @@ -2,14 +2,13 @@ from __future__ import print_function -import commands import json import os import subprocess import sys import time -LWAN_PATH = './build/testrunner/testrunner' +LWAN_PATH = '../../build/src/bin/testrunner/testrunner' for arg in sys.argv[1:]: if not arg.startswith('-') and os.path.exists(arg): LWAN_PATH = arg @@ -38,19 +37,18 @@ def weighttp(url, n_threads, n_connections, n_requests, keep_alive): '-t %(n_threads)d ' \ '-c %(n_connections)d ' \ '-n %(n_requests)d ' \ - '-j ' \ '%(url)s 2> /dev/null' % locals() clearstderrline() sys.stderr.write('*** %s\r' % command) - output = commands.getoutput(command) + output = subprocess.getoutput(command) return json.loads(output) def weighttp_has_json_output(): - output = commands.getoutput('weighttp -j') + output = subprocess.getoutput('weighttp -j') return not 'unknown option: -j' in output From 3b0aeacc1ea91379394b3701ba3ecf24fd34d7fa Mon Sep 17 00:00:00 2001 From: Jacky_Yin Date: Sun, 12 Sep 2021 13:16:55 +0800 Subject: [PATCH 2/3] chore: add WARNING for testsuite and benchmark --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38052eace..bba69d3cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -364,6 +364,8 @@ if (LUA_FOUND AND PYTHONINTERP_FOUND) DEPENDS testrunner WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMENT "Running benchmark.") +else () + message(WARNING "Lua or Python3 not found, skip target testsuite and benchmark.") endif() add_subdirectory(src) From 09783cbb18998814e7bc3e7c295801c51099ae63 Mon Sep 17 00:00:00 2001 From: Jacky_Yin Date: Tue, 14 Sep 2021 12:01:03 +0800 Subject: [PATCH 3/3] fix: accomodate weighttp option and output --- src/scripts/benchmark.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/scripts/benchmark.py b/src/scripts/benchmark.py index 05a69e5e8..47130dc72 100755 --- a/src/scripts/benchmark.py +++ b/src/scripts/benchmark.py @@ -37,6 +37,7 @@ def weighttp(url, n_threads, n_connections, n_requests, keep_alive): '-t %(n_threads)d ' \ '-c %(n_connections)d ' \ '-n %(n_requests)d ' \ + '-q ' \ '%(url)s 2> /dev/null' % locals() clearstderrline() @@ -149,11 +150,6 @@ def log(self, keep_alive, n_connections, rps, kbps, _2xx, _3xx, _4xx, _5xx): if __name__ == '__main__': - if not weighttp_has_json_output(): - print('This script requires a special version of weighttp which supports JSON') - print('output. Get it at http://github.com/lpereira/weighttp') - sys.exit(1) - plot = cmdlineboolarg('--plot') xkcd = cmdlineboolarg('--xkcd') n_threads = cmdlineintarg('--threads', 2) @@ -181,7 +177,7 @@ def log(self, keep_alive, n_connections, rps, kbps, _2xx, _3xx, _4xx, _5xx): status = results['status_codes'] output.log(keep_alive, n_connections, results['reqs_per_sec'], - results['kbyte_per_sec'], status['2xx'], status['3xx'], + results['kBps_per_sec'], status['2xx'], status['3xx'], status['4xx'], status['5xx']) sleepwithstatus('Waiting for keepalive connection timeout', keep_alive_timeout * 1.1)