From patchwork Fri Dec 9 10:02:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 87405 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp222400qgi; Fri, 9 Dec 2016 02:03:28 -0800 (PST) X-Received: by 10.99.143.9 with SMTP id n9mr75059598pgd.133.1481277807953; Fri, 09 Dec 2016 02:03:27 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id q127si33065824pfb.189.2016.12.09.02.03.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Dec 2016 02:03:27 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-443871-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-443871-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-443871-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=iVuJPrP+JDyULJKaBzBmzqzRla37WvOBVsogHFcjC4U1PBwUTm vIz/sOWXY0LHjnf1rvU3B1bq7uZJKeL1xqLr+/jTtWIBrDMnKXg7Tv844eSEmy/G W4VlVV7n2ycLyitjudlbkKSzPhiJpEOKMqGxxq7DpdIKdBIorD4dp3Gkc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=kDbftskhVw2MALgtlN9+fWlwaQk=; b=t1bCXlfU4rjGfKdShfqk TSPpGhZRcUKyTw41h6niWb3G4WiL4ym8U1jTKpdpN0hOUElKGCuJa5sFYlkLFBy3 1wZU+AInTTzgualJ+gpgOq/iawfN7gxAo9hWMWIWbFV3N+eGrayMGbzjvew3X/iS v1oY2z3D7Jwfwoo4Rmqw/w4= Received: (qmail 75913 invoked by alias); 9 Dec 2016 10:02:51 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 75862 invoked by uid 89); 9 Dec 2016 10:02:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=enhances, 18s, H*MI:0079, prediction X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Dec 2016 10:02:39 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id EAF2BABC3; Fri, 9 Dec 2016 10:02:36 +0000 (UTC) To: GCC Patches Cc: Jan Hubicka From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] Enhance analyze_brprob script Message-ID: Date: Fri, 9 Dec 2016 11:02:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-IsSubscribed: yes Following patch enhances scripts and fixed various small issues. Ready to be installed? Martin >From 626b70eb3526d848e2f1741f8b2384c518d2067b Mon Sep 17 00:00:00 2001 From: marxin Date: Fri, 9 Dec 2016 11:00:16 +0100 Subject: [PATCH] Enhance analyze_brprob script contrib/ChangeLog: 2016-12-09 Martin Liska * analyze_brprob.py: Add new column to output and new sorting option. Fix coding style to not exceed 80 characters. * analyze_brprob_spec.py: Add new sorting option. Fix coding style to not exceed 80 characters. --- contrib/analyze_brprob.py | 39 ++++++++++++++++++++++++++++----------- contrib/analyze_brprob_spec.py | 9 ++++++--- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/contrib/analyze_brprob.py b/contrib/analyze_brprob.py index 7e66271..b4dbbc4 100755 --- a/contrib/analyze_brprob.py +++ b/contrib/analyze_brprob.py @@ -69,7 +69,8 @@ import argparse from math import * -counter_aggregates = set(['combined', 'first match', 'DS theory', 'no prediction']) +counter_aggregates = set(['combined', 'first match', 'DS theory', + 'no prediction']) def percentage(a, b): return 100.0 * a / b @@ -93,12 +94,16 @@ class Summary: def __init__(self, name): self.name = name self.branches = 0 + self.successfull_branches = 0 self.count = 0 self.hits = 0 self.fits = 0 def get_hitrate(self): - return self.hits / self.count + return 100.0 * self.hits / self.count + + def get_branch_hitrate(self): + return 100.0 * self.successfull_branches / self.branches def count_formatted(self): v = self.count @@ -109,10 +114,11 @@ class Summary: return "%.1f%s" % (v, 'Y') def print(self, branches_max, count_max): - print('%-40s %8i %5.1f%% %6.2f%% / %6.2f%% %14i %8s %5.1f%%' % + print('%-40s %8i %5.1f%% %11.2f%% %7.2f%% / %6.2f%% %14i %8s %5.1f%%' % (self.name, self.branches, percentage(self.branches, branches_max), - percentage(self.hits, self.count), + self.get_branch_hitrate(), + self.get_hitrate(), percentage(self.fits, self.count), self.count, self.count_formatted(), percentage(self.count, count_max))) @@ -129,11 +135,16 @@ class Profile: s = self.heuristics[name] s.branches += 1 + s.count += count if prediction < 50: hits = count - hits + remaining = count - hits + if hits >= remaining: + s.successfull_branches += 1 + s.hits += hits - s.fits += max(hits, count - hits) + s.fits += max(hits, remaining) def add_loop_niter(self, niter): if niter > 0: @@ -150,15 +161,18 @@ class Profile: branches_max = self.branches_max() sorter = lambda x: x.branches - if sorting == 'hitrate': + if sorting == 'branch-hitrate': + sorter = lambda x: x.get_branch_hitrate() + elif sorting == 'hitrate': sorter = lambda x: x.get_hitrate() elif sorting == 'coverage': sorter = lambda x: x.count elif sorting == 'name': sorter = lambda x: x.name.lower() - print('%-40s %8s %6s %-16s %14s %8s %6s' % (group_name, - 'BRANCHES', '(REL)', 'HITRATE', 'COVERAGE', 'COVERAGE', '(REL)')) + print('%-40s %8s %6s %12s %18s %14s %8s %6s' % + ('HEURISTICS', 'BRANCHES', '(REL)', + 'BR. HITRATE', 'HITRATE', 'COVERAGE', 'COVERAGE', '(REL)')) for h in sorted(heuristics, key = sorter): h.print(branches_max, count_max) @@ -183,12 +197,15 @@ class Profile: print(' median # of iter: %.2f' % median(self.niter_vector)) for v in [1, 5, 10, 20, 30]: cut = 0.01 * v - print(' avg. (%d%% cutoff) # of iter: %.2f' % (v, average_cutoff(self.niter_vector, cut))) + print(' avg. (%d%% cutoff) # of iter: %.2f' + % (v, average_cutoff(self.niter_vector, cut))) parser = argparse.ArgumentParser() -parser.add_argument('dump_file', metavar = 'dump_file', help = 'IPA profile dump file') +parser.add_argument('dump_file', metavar = 'dump_file', + help = 'IPA profile dump file') parser.add_argument('-s', '--sorting', dest = 'sorting', - choices = ['branches', 'hitrate', 'coverage', 'name'], default = 'branches') + choices = ['branches', 'branch-hitrate', 'hitrate', 'coverage', 'name'], + default = 'branches') args = parser.parse_args() diff --git a/contrib/analyze_brprob_spec.py b/contrib/analyze_brprob_spec.py index effdc21..908db39 100755 --- a/contrib/analyze_brprob_spec.py +++ b/contrib/analyze_brprob_spec.py @@ -25,9 +25,11 @@ import argparse script_location = os.path.realpath(__file__) parser = argparse.ArgumentParser() -parser.add_argument('location', metavar = 'dump_file', help = 'Location with SPEC benchmarks') +parser.add_argument('location', metavar = 'dump_file', + help = 'Location with SPEC benchmarks') parser.add_argument('-s', '--sorting', dest = 'sorting', - choices = ['branches', 'hitrate', 'coverage', 'name'], default = 'branches') + choices = ['branches', 'branch-hitrate', 'hitrate', 'coverage', 'name'], + default = 'branches') args = parser.parse_args() @@ -52,7 +54,8 @@ for b in sorted(benchmarks): print() print(b) sys.stdout.flush() - p = [os.path.join(os.path.dirname(script_location), 'analyze_brprob.py'), temp.name, '--sorting', args.sorting] + p = [os.path.join(os.path.dirname(script_location), 'analyze_brprob.py'), + temp.name, '--sorting', args.sorting] p = subprocess.check_call(p) sys.stdout.flush() -- 2.10.2