Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix becnhmark.py and add warning in cmake file #311

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
16 changes: 5 additions & 11 deletions src/scripts/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -38,19 +37,19 @@ def weighttp(url, n_threads, n_connections, n_requests, keep_alive):
'-t %(n_threads)d ' \
'-c %(n_connections)d ' \
'-n %(n_requests)d ' \
'-j ' \
'-q ' \
'%(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


Expand Down Expand Up @@ -151,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)
Expand Down Expand Up @@ -183,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)

Expand Down