diff --git a/tools/parse_session_stats.py b/tools/parse_session_stats.py index 9c7767bc9..ea8c6b3d4 100755 --- a/tools/parse_session_stats.py +++ b/tools/parse_session_stats.py @@ -129,7 +129,11 @@ for i in range(0, 6): def plot_fun(script): - ret = os.system('gnuplot "%s" 2>/dev/null' % script) + try: + ret = os.system('gnuplot "%s" 2>/dev/null' % script) + except Exception as e: + print('please install gnuplot: sudo apt install gnuplot') + raise e if ret != 0 and ret != 256: print('gnuplot failed: %d\n' % ret) raise Exception("abort") diff --git a/tools/run_benchmark.py b/tools/run_benchmark.py index f366ecdfc..ae74378a4 100755 --- a/tools/run_benchmark.py +++ b/tools/run_benchmark.py @@ -6,6 +6,7 @@ import time import shutil import subprocess import sys +import multiprocessing cache_size = 300 # in MiB @@ -13,28 +14,30 @@ toolset = '' if len(sys.argv) > 1: toolset = sys.argv[1] -ret = os.system('cd ../examples && bjam profile statistics=on %s stage_client_test' % toolset) +ret = os.system('cd ../examples && b2 -j %d profile %s stage_client_test' + % (multiprocessing.cpu_count(), toolset)) if ret != 0: print('ERROR: build failed: %d' % ret) sys.exit(1) -ret = os.system('cd ../examples && bjam release %s stage_connection_tester' % toolset) +ret = os.system('cd ../examples && b2 -j %d release %s stage_connection_tester' + % (multiprocessing.cpu_count(), toolset)) if ret != 0: print('ERROR: build failed: %d' % ret) sys.exit(1) try: os.remove('.ses_state') -except Exception as e: - print(e) +except Exception: + pass try: shutil.rmtree('.resume') -except Exception as e: - print(e) +except Exception: + pass try: shutil.rmtree('cpu_benchmark') -except Exception as e: - print(e) +except Exception: + pass if not os.path.exists('cpu_benchmark.torrent'): ret = os.system('../examples/connection_tester gen-torrent -s 10000 -n 15 -t cpu_benchmark.torrent') @@ -72,9 +75,11 @@ def run_test(name, test_cmd, client_arg, num_peers): pass start = time.time() - client_cmd = ('../examples/client_test -p %d cpu_benchmark.torrent -k -z -H -X -q 120 %s' - '-h -c %d -T %d -C %d -f %s/events.log').format( - port, client_arg, num_peers * 2, num_peers * 2, cache_size * 16, output_dir) + client_cmd = '../examples/client_test -k --listen_interfaces=127.0.0.1:%d cpu_benchmark.torrent ' \ + '--disable_hash_checks=1 --enable_dht=0 --enable_lsd=0 --enable_upnp=0 --enable_natpmp=0 ' \ + '-e 120 %s -O --allow_multiple_connections_per_ip=1 --connections_limit=%d -T %d ' \ + '--cache_size=%d -f %s/events.log --alert_mask=8747' \ + % (port, client_arg, num_peers * 2, num_peers * 2, cache_size * 16, output_dir) test_cmd = '../examples/connection_tester %s -c %d -d 127.0.0.1 -p %d -t cpu_benchmark.torrent' % ( test_cmd, num_peers, port) @@ -103,17 +108,17 @@ def run_test(name, test_cmd, client_arg, num_peers): print('analyzing proile...') os.system('gprof ../examples/client_test >%s/gprof.out' % output_dir) print('generating profile graph...') - os.system('python gprof2dot.py --strip <%s/gprof.out | dot -Tpng -o %s/cpu_profile.png' % (output_dir, output_dir)) + try: + os.system('gprof2dot --strip <%s/gprof.out | dot -Tpng -o %s/cpu_profile.png' % (output_dir, output_dir)) + except Exception: + print('please install gprof2dot and dot:\nsudo pip install gprof2dot\nsudo apt install graphviz') + + os.system('python parse_session_stats.py %s/events.log' % output_dir) - os.system('python parse_session_stats.py session_stats/*.log') try: shutil.move('session_stats_report', '%s/session_stats_report' % output_dir) except Exception: pass - try: - shutil.move('session_stats', '%s/session_stats' % output_dir) - except Exception: - pass run_test('download', 'upload', '', 50)