From patchwork Mon Aug 7 19:31: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: 798834 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-82811-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="rXhyGHh1"; 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 3xR72S3SNbz9s5L for ; Tue, 8 Aug 2017 05:32:00 +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=ZZoU8C980lrRD+OBaAmqaXSwJaQ7qc6ClqUn3FlQmYPzxjF4SpGhK DnA/rKeDKNWdM683SNaSg2m89mYSXmWda0vmgkbMb5CypAuiNSBHhmyrdaVaPcK0 K8HGrCsBl2da6rbsCdUbe0VL3fix2zN/EaJ257XGSlAaMYQhDyIKzw= 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=MDfbnIM3xEH8iNvUF2GaDRPU/zc=; b=rXhyGHh1JFVFqpqKBx03xo+Oy26X RwmQE7zA5RnBYESDqaw748NTBi/en5G+G4GmvcPLSBdPDG8kapCeCMgAyd6aqTwo bwnqX8rtexT4Tt75/M+P5+seR1KH5XDKwI43Ab9JaYd5m+owd2w/I/7lzeAhsnQy tTGeUHl3HdoKO8s= Received: (qmail 18940 invoked by alias); 7 Aug 2017 19:31:23 -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 18777 invoked by uid 89); 7 Aug 2017 19:31:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy= X-HELO: homiemail-a68.g.dreamhost.com From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [COMMITTED] benchtests: Allow selecting baseline for compare_string.py Date: Tue, 8 Aug 2017 01:01:06 +0530 Message-Id: <1502134266-31391-1-git-send-email-siddhesh@sourceware.org> This patch allows one to provide the function name using an optional -base option to compare all other functions against. This is useful when pitching one implementation of a string function against alternatives. In the absence of this option, comparisons are done against the first ifunc in the list. * benchtests/scripts/compare_strings.py (main): Add an optional -base option. (process_results): New argument base_func. --- ChangeLog | 4 ++++ benchtests/scripts/compare_strings.py | 28 ++++++++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 887fc71..efdd9b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2017-08-07 Siddhesh Poyarekar + * benchtests/scripts/compare_strings.py (main): Add an + optional -base option. + (process_results): New argument base_func. + * benchtests/bench-memcpy.c (test_main): Use TEST_NAME instead of hardcoding memcpy. * benchtests/bench-memcpy-large.c (test_name): Likewise. diff --git a/benchtests/scripts/compare_strings.py b/benchtests/scripts/compare_strings.py index 9d73ec4..43e70eb 100755 --- a/benchtests/scripts/compare_strings.py +++ b/benchtests/scripts/compare_strings.py @@ -21,6 +21,7 @@ Given a string benchmark result file, print a table with comparisons with a baseline. The baseline is the first function, which typically is the builtin function. """ + import sys import os import json @@ -74,7 +75,7 @@ def draw_graph(f, v, ifuncs, results): pylab.savefig('%s-%s.png' % (f, v), bbox_inches='tight') -def process_results(results, attrs): +def process_results(results, attrs, base_func): """ Process results and print them Args: @@ -84,6 +85,10 @@ def process_results(results, attrs): for f in results['functions'].keys(): print('Function: %s' % f) + 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) @@ -91,19 +96,17 @@ def process_results(results, attrs): graph_res = {} for res in results['functions'][f]['results']: attr_list = ['%s=%s' % (a, res[a]) for a in attrs] - first = True + i = 0 key = ','.join(attr_list) sys.stdout.write('%s: \t' % key) graph_res[key] = res['timings'] for t in res['timings']: sys.stdout.write ('%.2f' % t) - if first: - first = False - else: - diff = (res['timings'][0] - t) * 100 / res['timings'][0] - + if i != base_index: + diff = (res['timings'][base_index] - t) * 100 / res['timings'][base_index] sys.stdout.write (' (%.2f%%)' % diff) sys.stdout.write('\t') + i = i + 1 print('') draw_graph(f, v, results['functions'][f]['ifuncs'], graph_res) @@ -114,15 +117,20 @@ def main(args): Take a string benchmark output file and compare timings. """ if len(args) < 3: - print('Usage: %s attr1 [attr2 ...]' % sys.argv[0]) + 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] - attrs = args[2:] + if args[2].find('-base=') == 0: + base_func = args[2][6:] + attrs = args[3:] + else: + attrs = args[2:] results = parse_file(filename, schema_filename) - process_results(results, attrs) + process_results(results, attrs, base_func) if __name__ == '__main__':