From patchwork Sat Sep 16 10:11:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 814485 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-84662-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Eq+HClrd"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xvSjC27dcz9t2l for ; Sat, 16 Sep 2017 20:11:25 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=byNlZ7XNScMRtPBUD+MEwRONQJgwtSR/zLvSfS29BOG8nxzVcizMZ tbzc+VucCCBAXJ4QUhFN7wYnAakXmwvyFQlm7zTc7wXjoaygrSGFV3cypo64pNFX WVyw5VVlia/qX+ru6i+NttcjUNrhvBkIIxiCgNdggu0BaLh+fPmG/I= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=Zrhc85Iu+VnXXIRStB39P3Y7EwA=; b=Eq+HClrdo47aDGyS5RZCeOSnUF4S KspmywPGPcPtDLs2i+BgjT2DlhWQDxwQOJ231IX+MJQGk2ZwW49omUi5yGd1Exzp zVpd2NXFN6ycALhGBs4Wf46u3Og+5NhNTn7GkseXzxwCuc4dYift7t2nz1rhVfCL PNgsq4pXVlnxjuc= Received: (qmail 13612 invoked by alias); 16 Sep 2017 10:11:19 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 13602 invoked by uid 89); 16 Sep 2017 10:11:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_NEUTRAL, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: homiemail-a114.g.dreamhost.com From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [COMMITTED 1/3] benchtests: Use argparse to parse arguments Date: Sat, 16 Sep 2017 15:41:04 +0530 Message-Id: <1505556666-3043-1-git-send-email-siddhesh@sourceware.org> Make the script more usable by adding proper command line options along with a way to query the options. The script is capable of doing a bunch of things right now like choosing a base for comparison, choosing to generate graphs, etc. and they should be accessible via command line switches. * benchtests/scripts/compare_strings.py: Use argparse. * benchtests/README: Document existence of compare_strings.py. --- ChangeLog | 5 +++++ benchtests/README | 11 +++++++++++ benchtests/scripts/compare_strings.py | 35 +++++++++++++++++++++++------------ 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 58acb54..fd9cc0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-09-16 Siddhesh Poyarekar + + * benchtests/scripts/compare_strings.py: Use argparse. + * benchtests/README: Document existence of compare_strings.py. + 2017-09-15 Joseph Myers * math/s_fma.c: Include . diff --git a/benchtests/README b/benchtests/README index b015acf..9aa750a 100644 --- a/benchtests/README +++ b/benchtests/README @@ -122,3 +122,14 @@ To add a benchset for `foo': - Write your bench-foo.c that prints out the measurements to stdout. - On execution, a bench-foo.out is created in $(objpfx) with the contents of stdout. + +Reading String Benchmark Results: +================================ + +Some of the string benchmark results are now in JSON to make it easier to read +in scripts. Use the benchtests/compare_strings.py script to show the results +in a tabular format, generate graphs and more. Run + + benchtests/scripts/compare_strings.py -h + +for usage information. diff --git a/benchtests/scripts/compare_strings.py b/benchtests/scripts/compare_strings.py index b3c57e2..3ca9429 100755 --- a/benchtests/scripts/compare_strings.py +++ b/benchtests/scripts/compare_strings.py @@ -28,6 +28,7 @@ import sys import os import json import pylab +import argparse try: import jsonschema as validator @@ -118,22 +119,32 @@ def main(args): Take a string benchmark output file and compare timings. """ - if len(args) < 3: - print('Usage: %s [-base=ifunc_name] attr1 [attr2 ...]' % sys.argv[0]) - sys.exit(os.EX_USAGE) base_func = None - filename = args[0] - schema_filename = args[1] - if args[2].find('-base=') == 0: - base_func = args[2][6:] - attrs = args[3:] - else: - attrs = args[2:] + filename = args.input + schema_filename = args.schema + base_func = args.base + attrs = args.attributes.split(',') - results = parse_file(filename, schema_filename) + results = parse_file(args.input, args.schema) process_results(results, attrs, base_func) if __name__ == '__main__': - main(sys.argv[1:]) + parser = argparse.ArgumentParser() + + # The required arguments. + req = parser.add_argument_group(title='required arguments') + req.add_argument('-a', '--attributes', required=True, + help='Comma separated list of benchmark attributes.') + req.add_argument('-i', '--input', required=True, + help='Input JSON benchmark result file.') + req.add_argument('-s', '--schema', required=True, + help='Schema file to validate the result file.') + + # Optional arguments. + parser.add_argument('-b', '--base', + help='IFUNC variant to set as baseline.') + + args = parser.parse_args() + main(args) From patchwork Sat Sep 16 10:11:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 814486 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-84663-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="uPhS1lHk"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xvSjK2QYXz9t2l for ; Sat, 16 Sep 2017 20:11:33 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=X5T3AIzZRGhOdqBIe4FPbtDJXycyRAF 5Sevw9lIn21XxcjSCZ1vwbzzgdTsan/qTNYUs6G7QicSKW30NOYLhq6uHV1cUYq5 UAhVuF1kjqGFLyxE05Y0zS9Rj8uBH/C1tE/MjoC72QzEYiQuCsLK4e/i7X6NbwWL Lxgj87c2jEsI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=t+BGvTON7AJcWb2OYURYEgRyjE0=; b=uPhS1 lHkIF/po1OsFeHpuR7j0f9c/NlZLePY+liqKV24Z41Mq/jgDWUCRzzEDBDl0WTpz Uq41h/dTnBUfGOPZCV4rz2L+xF35KL3WUxZiHg6SXOyyH3Jrd0zvglJi2XYe2Auw +Yo8tXID/n6g2D84fApFsrHVvj80i0xtjufkS0= Received: (qmail 13993 invoked by alias); 16 Sep 2017 10:11:22 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 13919 invoked by uid 89); 16 Sep 2017 10:11:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=Hx-languages-length:2273 X-HELO: homiemail-a114.g.dreamhost.com From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [COMMITTED 2/3] benchtests: Make compare_strings.py output a bit prettier Date: Sat, 16 Sep 2017 15:41:05 +0530 Message-Id: <1505556666-3043-2-git-send-email-siddhesh@sourceware.org> In-Reply-To: <1505556666-3043-1-git-send-email-siddhesh@sourceware.org> References: <1505556666-3043-1-git-send-email-siddhesh@sourceware.org> Make the column widths for the outputs fixed so that they look a little less messy. They will still look bad with lots of IFUNCs (like on x86) but it's still a step forward. * benchtests/scripts/compare_strings.py (process_results): Better spacing for output. --- ChangeLog | 3 +++ benchtests/scripts/compare_strings.py | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index fd9cc0c..20746e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2017-09-16 Siddhesh Poyarekar + * benchtests/scripts/compare_strings.py (process_results): + Better spacing for output. + * benchtests/scripts/compare_strings.py: Use argparse. * benchtests/README: Document existence of compare_strings.py. diff --git a/benchtests/scripts/compare_strings.py b/benchtests/scripts/compare_strings.py index 3ca9429..1f0be3b 100755 --- a/benchtests/scripts/compare_strings.py +++ b/benchtests/scripts/compare_strings.py @@ -88,26 +88,28 @@ def process_results(results, attrs, base_func): for f in results['functions'].keys(): print('Function: %s' % f) + v = results['functions'][f]['bench-variant'] + print('Variant: %s' % v) + base_index = 0 if base_func: base_index = results['functions'][f]['ifuncs'].index(base_func) - print('\t'.join(results['functions'][f]['ifuncs'])) - v = results['functions'][f]['bench-variant'] - print('Variant: %s' % v) - print("=" * 80) + print("%36s%s" % (' ', '\t'.join(results['functions'][f]['ifuncs']))) + print("=" * 120) graph_res = {} for res in results['functions'][f]['results']: attr_list = ['%s=%s' % (a, res[a]) for a in attrs] i = 0 - key = ','.join(attr_list) - sys.stdout.write('%s: \t' % key) + key = ', '.join(attr_list) + sys.stdout.write('%36s: ' % key) graph_res[key] = res['timings'] for t in res['timings']: - sys.stdout.write ('%.2f' % t) + sys.stdout.write ('%12.2f' % t) if i != base_index: - diff = (res['timings'][base_index] - t) * 100 / res['timings'][base_index] - sys.stdout.write (' (%.2f%%)' % diff) + base = res['timings'][base_index] + diff = (base - t) * 100 / base + sys.stdout.write (' (%6.2f%%)' % diff) sys.stdout.write('\t') i = i + 1 print('') From patchwork Sat Sep 16 10:11:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 814487 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-84664-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="KSd0PsM4"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xvSjT3yl4z9t2l for ; Sat, 16 Sep 2017 20:11:41 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=p+Ji7LF682l9JOghkJj2BAySlS1A85m 77ZX7rUfzcGF2WtX9bYvVIxjNUN9WY7ETx1dV76c2P8wSNExA+yfxnmQ4jiquKEk uti6U7mofmahHs2R/UlszgkfvD0cxLqsH4IN2ibMZ5gfgPbX7wVAL2Pd74AQorCa WYx8vbczfERk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=3IC9IFZ/6cBR1HwrUbfESMgTy0o=; b=KSd0P sM4IXhGui08JgHW5hwaHiIs+FWvOazZ+Qj2bXy6gLWTVQqW74kE8A89YnSeZP4se GI55TE6s6FseFmNfdTW9qIChOhgDv/+90WItE74e3rXxIP8SBn7hEu3Iqik3CgAA bMBrCEb5FDnmfwmk5LyTIb6Vi/ZoMxyt203X3c= Received: (qmail 14404 invoked by alias); 16 Sep 2017 10:11:24 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 14299 invoked by uid 89); 16 Sep 2017 10:11:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=Hx-languages-length:2586 X-HELO: homiemail-a114.g.dreamhost.com From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [COMMITTED 3/3] benchtests: New -g option to generate graphs in compare_strings.py Date: Sat, 16 Sep 2017 15:41:06 +0530 Message-Id: <1505556666-3043-3-git-send-email-siddhesh@sourceware.org> In-Reply-To: <1505556666-3043-1-git-send-email-siddhesh@sourceware.org> References: <1505556666-3043-1-git-send-email-siddhesh@sourceware.org> The compare_strings.py option unconditionally generates a graph PNG image of the input data, which can be unnecessary and slow. Put this behind an optional flag -g. * benchtests/scripts/compare_strings.py: New option -g. (draw_graph): Print a message that a graph is being generated. (process_results): Generate graph only if -g is passed. (main): Process option -g. --- ChangeLog | 5 +++++ benchtests/scripts/compare_strings.py | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20746e6..ea0b671 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2017-09-16 Siddhesh Poyarekar + * benchtests/scripts/compare_strings.py: New option -g. + (draw_graph): Print a message that a graph is being generated. + (process_results): Generate graph only if -g is passed. + (main): Process option -g. + * benchtests/scripts/compare_strings.py (process_results): Better spacing for output. diff --git a/benchtests/scripts/compare_strings.py b/benchtests/scripts/compare_strings.py index 1f0be3b..65119ed 100755 --- a/benchtests/scripts/compare_strings.py +++ b/benchtests/scripts/compare_strings.py @@ -57,6 +57,7 @@ def draw_graph(f, v, ifuncs, results): ifuncs: List of ifunc names results: Dictionary of results for each test criterion """ + print('Generating graph for %s, variant \'%s\'' % (f, v)) xkeys = results.keys() pylab.clf() @@ -78,7 +79,7 @@ def draw_graph(f, v, ifuncs, results): pylab.savefig('%s-%s.png' % (f, v), bbox_inches='tight') -def process_results(results, attrs, base_func): +def process_results(results, attrs, base_func, graph): """ Process results and print them Args: @@ -113,7 +114,9 @@ def process_results(results, attrs, base_func): sys.stdout.write('\t') i = i + 1 print('') - draw_graph(f, v, results['functions'][f]['ifuncs'], graph_res) + + if graph: + draw_graph(f, v, results['functions'][f]['ifuncs'], graph_res) def main(args): @@ -129,7 +132,7 @@ def main(args): attrs = args.attributes.split(',') results = parse_file(args.input, args.schema) - process_results(results, attrs, base_func) + process_results(results, attrs, base_func, args.graph) if __name__ == '__main__': @@ -147,6 +150,8 @@ if __name__ == '__main__': # Optional arguments. parser.add_argument('-b', '--base', help='IFUNC variant to set as baseline.') + parser.add_argument('-g', '--graph', action='store_true', + help='Generate a graph from results.') args = parser.parse_args() main(args)