From patchwork Tue Jun 12 14:29:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 27751 Received: (qmail 116482 invoked by alias); 12 Jun 2018 14:30:00 -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 116462 invoked by uid 89); 12 Jun 2018 14:29:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, MISSING_HEADERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=tight, objections X-HELO: mail-oi0-f67.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:cc; bh=faXlhEmuAnEmeiRfUEyNFG49Dglp/Bo6k2Orah/RJQc=; b=ju0CQgKy0e7YTtTAPUIVUMmNWXxgrfrELY5WM85rLjy/tn8NwIzDqLfcxHd1JsPMy1 HiKixnE2SUzhDJ0+YYRgCaKd8r3qcmRFLjMn77yVfXxRbv1IYpoFYzXG8USs3vvb5Ivx URYSdoYWfLpEWFHh2XeEASN7aZYu8SgeRM/rs+ptdtpTfH6WSIZ+OhbDsvJXla5ehJb+ cbnKs9uKpe2/JpJt076F9o6/NRWq2FXSXsPvjXdAxz/wh4QmJp763ZIwsR21mmzg5JAx tt71AoBcyxYD/QB2k2Q7ZZsJmFpaOCQ1CBN9MWjzUuMhl3RitXG83CDG1oVH3it+u8Oh FAiw== X-Gm-Message-State: APt69E2QsbFac/fcHZCvwhAwArbsoz9Uke6uUoO+Bq2lPNLw9fZLwnIz QzQe/sr12np7L5Su64fc+LPRjJJ2atLYmls875o= X-Google-Smtp-Source: ADUXVKKaTAYbMXZLSRWfMbpc1u28EWbHiv/76EsfrznTLAuvw55JTYu1kC4eNdlg2Q+4Tj6BZuGkvA2ul1Y+cg21hIM= X-Received: by 2002:aca:4c12:: with SMTP id z18-v6mr1999159oia.311.1528813796026; Tue, 12 Jun 2018 07:29:56 -0700 (PDT) MIME-Version: 1.0 From: "H.J. Lu" Date: Tue, 12 Jun 2018 07:29:55 -0700 Message-ID: Subject: PING: [PATCH] benchtests: Add -f/--functions argument Cc: GNU C Library On Thu, May 24, 2018 at 10:40 AM, H.J. Lu wrote: > On x86-64, there may be multiple IFUNC implementations for a given > function. But we may be only interested in a subset of them. This > patch adds -f/--functions argument to compare a subset of IFUNC > implementations. > > Any comments? > > > H.J. > --- > * benchtests/scripts/compare_strings.py (process_results): Add > funcs argument. Compare only functions which are selected. > (main): Check if base function is among selected functions. > Pass selected functions to process_results. > (__main__): Add -f/--functions argument. I rebased my patch against the current master. Any comments, objections? From cfed5f5b78c22eb7927e68a603fa532c73183c52 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 24 May 2018 10:12:26 -0700 Subject: [PATCH] benchtests: Add -f/--functions argument On x86-64, there may be multiple IFUNC implementations for a given function. But we may be only interested in a subset of them. This patch adds -f/--functions argument to compare a subset of IFUNC implementations. * benchtests/scripts/compare_strings.py (process_results): Add funcs argument. Compare only functions which are selected. (main): Check if base function is among selected functions. Pass selected functions to process_results. (__main__): Add -f/--functions argument. --- benchtests/scripts/compare_strings.py | 52 +++++++++++++++++++++------ 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/benchtests/scripts/compare_strings.py b/benchtests/scripts/compare_strings.py index ddce84a3ac..e3ad8ff058 100755 --- a/benchtests/scripts/compare_strings.py +++ b/benchtests/scripts/compare_strings.py @@ -82,19 +82,41 @@ def draw_graph(f, v, ifuncs, results): pylab.savefig('%s-%s.png' % (f, v), bbox_inches='tight') -def process_results(results, attrs, base_func, graph, no_diff, no_header): +def process_results(results, attrs, funcs, base_func, graph, no_diff, no_header): """ Process results and print them Args: results: JSON dictionary of results attrs: Attributes that form the test criteria + funcs: Functions that are selected """ for f in results['functions'].keys(): v = results['functions'][f]['bench-variant'] + selected = {} + index = 0 base_index = 0 + if funcs: + ifuncs = [] + first_func = True + for i in results['functions'][f]['ifuncs']: + if i in funcs: + if first_func: + base_index = index + first_func = False + selected[index] = 1 + ifuncs.append(i) + else: + selected[index] = 0 + index += 1 + else: + ifuncs = results['functions'][f]['ifuncs'] + for i in ifuncs: + selected[index] = 1 + index += 1 + if base_func: try: base_index = results['functions'][f]['ifuncs'].index(base_func) @@ -106,7 +128,7 @@ def process_results(results, attrs, base_func, graph, no_diff, no_header): if not no_header: print('Function: %s' % f) print('Variant: %s' % v) - print("%36s%s" % (' ', '\t'.join(results['functions'][f]['ifuncs']))) + print("%36s%s" % (' ', '\t'.join(ifuncs))) print("=" * 120) graph_res = {} @@ -122,13 +144,14 @@ def process_results(results, attrs, base_func, graph, no_diff, no_header): sys.stdout.write('%36s: ' % key) graph_res[key] = res['timings'] for t in res['timings']: - sys.stdout.write ('%12.2f' % t) - if not no_diff: - if i != base_index: - base = res['timings'][base_index] - diff = (base - t) * 100 / base - sys.stdout.write (' (%6.2f%%)' % diff) - sys.stdout.write('\t') + if selected[i]: + sys.stdout.write ('%12.2f' % t) + if not no_diff: + if i != base_index: + base = res['timings'][base_index] + diff = (base - t) * 100 / base + sys.stdout.write (' (%6.2f%%)' % diff) + sys.stdout.write('\t') i = i + 1 print('') @@ -147,9 +170,16 @@ def main(args): schema_filename = args.schema base_func = args.base attrs = args.attributes.split(',') + if args.functions: + funcs = args.functions.split(',') + if base_func and not base_func in funcs: + print('Baseline function (%s) not found.' % base_func) + sys.exit(os.EX_DATAERR) + else: + funcs = None results = parse_file(args.input, args.schema) - process_results(results, attrs, base_func, args.graph, args.no_diff, args.no_header) + process_results(results, attrs, funcs, base_func, args.graph, args.no_diff, args.no_header) return os.EX_OK @@ -166,6 +196,8 @@ if __name__ == '__main__': help='Schema file to validate the result file.') # Optional arguments. + parser.add_argument('-f', '--functions', + help='Comma separated list of functions.') parser.add_argument('-b', '--base', help='IFUNC variant to set as baseline.') parser.add_argument('-g', '--graph', action='store_true', -- 2.17.1