Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp1978325imc; Fri, 22 Feb 2019 15:08:06 -0800 (PST) X-Google-Smtp-Source: AHgI3IbJ/c69BUJQZ4bk8JcAfx8rkxksj+0lnm1DjL1VvCEP6J/dEHQTgeLNEB6674LqAcK96cf3 X-Received: by 2002:a65:5003:: with SMTP id f3mr6287895pgo.39.1550876886032; Fri, 22 Feb 2019 15:08:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550876886; cv=none; d=google.com; s=arc-20160816; b=K1byBiX8klh9/Jv1pc5ZYdYODwwXk9+DoeCGBAp2QBOeYVTHlV0IRJr9VVifTEn4T6 cKIZCcYNvHPrf1zaQ+IzLjZR3gWv72RqTatLYk/oJIgCMvV8ntgGIrZoo2Rn9jq/BBYH FXw/ySt4AVmNBmpuXn3HBWWIwV0DTnfgTput+sO8siIA6ZvlUv2htQxxbV6s5gUaXPGf GyE2TTy+Yjef02u+BqQrNAiYTzEnjsOaEc3z9dgkfx6s5vH8kkL0wX+uOqyPwXNtYyVA BTlgPKWTba4dKkmk9eG4DU5J9la+lzGEoW9LvDxkZU3Oclo/WmSVOM4G1wM4GlB03JP+ rjdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ygmL2INE+O8lmSUBhqEXw+vVicaLsbLmbBkIM3l4UyU=; b=sWWYg3e3KoKRHmgmMXslGKP7e7m4OrDvgybEiUxefqzLCUVUfTQbzn2Jgjqy4tG4x5 8Fml0Z+FdY8qtssZp5DqOpRUUBsTSS4sNisqSsRq/oXe3v/HgC5ekV32ux+fHj+m7mwb QMXATJXRAOuDja216xbJDceHc5OzUn9MvGi+TMHQwTd4WEmVD32WpIvYuntms/v/Mi/k ExNRNSQbA0XCtMvczP8/OV2J8ULB+wFZdNUn4MpfIEypnw/R/RetIwvK9zDkQJOX2ws5 CcsWHJpMpm6A4Qso5z3qqA8NK54IYnYZwNiE3E7IJA6LdhDd+7kgBgIw11bnUFo39ulP grew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m24si2356748pls.211.2019.02.22.15.07.51; Fri, 22 Feb 2019 15:08:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727676AbfBVXHH (ORCPT + 99 others); Fri, 22 Feb 2019 18:07:07 -0500 Received: from mx2.suse.de ([195.135.220.15]:52586 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727656AbfBVXHG (ORCPT ); Fri, 22 Feb 2019 18:07:06 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C5593B60F; Fri, 22 Feb 2019 23:07:04 +0000 (UTC) From: Tony Jones To: linux-kernel@vger.kernel.org Cc: linux-perf-users@vger.kernel.org, acme@kernel.org, Tony Jones , Seeteena Thoufeek , Jiri Olsa Subject: [PATCH 12/15] perf script python: add Python3 support to stat-cpi.py Date: Fri, 22 Feb 2019 15:06:16 -0800 Message-Id: <20190222230619.17887-13-tonyj@suse.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190222230619.17887-1-tonyj@suse.de> References: <20190222230619.17887-1-tonyj@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support both Python2 and Python3 in the stat-cpi.py script There may be differences in the ordering of output lines due to differences in dictionary ordering etc. However the format within lines should be unchanged. The use of 'from __future__' implies the minimum supported Python2 version is now v2.6 Signed-off-by: Tony Jones Signed-off-by: Seeteena Thoufeek Cc: Jiri Olsa --- tools/perf/scripts/python/stat-cpi.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/perf/scripts/python/stat-cpi.py b/tools/perf/scripts/python/stat-cpi.py index a81ad8835a74..01fa933ff3cf 100644 --- a/tools/perf/scripts/python/stat-cpi.py +++ b/tools/perf/scripts/python/stat-cpi.py @@ -1,5 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 +from __future__ import print_function + data = {} times = [] threads = [] @@ -19,8 +21,8 @@ def store_key(time, cpu, thread): threads.append(thread) def store(time, event, cpu, thread, val, ena, run): - #print "event %s cpu %d, thread %d, time %d, val %d, ena %d, run %d" % \ - # (event, cpu, thread, time, val, ena, run) + #print("event %s cpu %d, thread %d, time %d, val %d, ena %d, run %d" % + # (event, cpu, thread, time, val, ena, run)) store_key(time, cpu, thread) key = get_key(time, event, cpu, thread) @@ -58,7 +60,7 @@ def stat__interval(time): if ins != 0: cpi = cyc/float(ins) - print "%15f: cpu %d, thread %d -> cpi %f (%d/%d)" % (time/(float(1000000000)), cpu, thread, cpi, cyc, ins) + print("%15f: cpu %d, thread %d -> cpi %f (%d/%d)" % (time/(float(1000000000)), cpu, thread, cpi, cyc, ins)) def trace_end(): pass @@ -74,4 +76,4 @@ def trace_end(): # if ins != 0: # cpi = cyc/float(ins) # -# print "time %.9f, cpu %d, thread %d -> cpi %f" % (time/(float(1000000000)), cpu, thread, cpi) +# print("time %.9f, cpu %d, thread %d -> cpi %f" % (time/(float(1000000000)), cpu, thread, cpi)) -- 2.20.1