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)