From patchwork Tue Apr 11 10:50:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 97237 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1748489qgd; Tue, 11 Apr 2017 03:52:57 -0700 (PDT) X-Received: by 10.55.3.66 with SMTP id 63mr38187206qkd.194.1491907977606; Tue, 11 Apr 2017 03:52:57 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b97si16057428qkh.311.2017.04.11.03.52.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 11 Apr 2017 03:52:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxtPr-0005Hr-6t for patch@linaro.org; Tue, 11 Apr 2017 06:52:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxtNT-0003YB-E3 for qemu-devel@nongnu.org; Tue, 11 Apr 2017 06:50:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxtNS-0004Sk-KP for qemu-devel@nongnu.org; Tue, 11 Apr 2017 06:50:27 -0400 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:35891) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cxtNS-0004SW-Ds for qemu-devel@nongnu.org; Tue, 11 Apr 2017 06:50:26 -0400 Received: by mail-wm0-x22c.google.com with SMTP id o81so59948602wmb.1 for ; Tue, 11 Apr 2017 03:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pw8r5OsCd6u2WxAvehHIQNEptMzKWzqRr+XWQrl54h4=; b=T2udFhhMpB7/0gsN3Ixf9/LhWwi978rzb7hJbMhp3/VtkIP45fkpqZ+l12KsjpH/C8 9tL5Xk0GLpksnSZPslmIbkZaiOSidkSrCnSSUu8ldbK8Z6UpWBjuCPPVkzSY2GNqhAgn j0p7ntKpQeuBM3SjdULb8+iVomvG6OucX6Chc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pw8r5OsCd6u2WxAvehHIQNEptMzKWzqRr+XWQrl54h4=; b=eYXNs3+VyBCcWUiFh+bzW5ygig6OQkbWZ+lWKATEq6WTQTF4h/nE4ESD+PdzbkoFuh HsnA0NNTv/2RfB4ofNxRpB1oiGgZg+9c7dEDrfWd9rV54hPxvNc8PVRxUGJhmnjeyxLJ 3nb7vlXJCdCxOcSRm9OT8pcfuY6ybzIdfdkhZ4UoSaIP08uKrCw415msQQbBpRd9/Cjr F/TYCmxihZQ18TQjU1pprrcDysBxYIwNqXkSnhP7/DbzJKfv64vniS3Y/idn/rPeWMmX ZoB9gN/UOZ3S9VKslphz2XyQ5XMo4SLisXyFOfXrxZa/gWdT6RV+ZP/FxK97Eu6oTNug aEZg== X-Gm-Message-State: AN3rC/5Jh8Xgdr2Q/55vcHJwi5B+vt+KI1c6BP+53NHvHSArnathQNHJQVXp4bbhnNMRmtci X-Received: by 10.28.215.147 with SMTP id o141mr12746636wmg.50.1491907825203; Tue, 11 Apr 2017 03:50:25 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id n13sm1962553wmi.28.2017.04.11.03.50.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Apr 2017 03:50:23 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 4B74C3E11B6; Tue, 11 Apr 2017 11:50:31 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: bobby.prani@gmail.com, rth@twiddle.net, stefanha@redhat.com Date: Tue, 11 Apr 2017 11:50:31 +0100 Message-Id: <20170411105031.28904-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170411105031.28904-1-alex.bennee@linaro.org> References: <20170411105031.28904-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22c Subject: [Qemu-devel] [PATCH v1 3/3] new script/analyse-tlb-flushes-simpletrace.py X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is a simple helper script to extract TLB flush stats from the a simpletrace file and plot the results. Signed-off-by: Alex Bennée --- scripts/analyse-tlb-flushes-simpletrace.py | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 scripts/analyse-tlb-flushes-simpletrace.py -- 2.11.0 diff --git a/scripts/analyse-tlb-flushes-simpletrace.py b/scripts/analyse-tlb-flushes-simpletrace.py new file mode 100755 index 0000000000..9a1191c154 --- /dev/null +++ b/scripts/analyse-tlb-flushes-simpletrace.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Generate a simple graph of flushes over time +# +# Author: Alex Bennée +# + +import os +import simpletrace +import argparse +import numpy as np +import matplotlib.pyplot as plt + +class CpuTLBFlushAnalyser(simpletrace.Analyzer): + "A simpletrace Analyser for extracting flush stats." + + def __init__(self): + self.stats = 0 + self.timestamps = [] + self.flush_self = [] + self.flush_async = [] + self.flush_synced = [] + + + def tlb_flush_stats(self, timestamp, flush_self, flush_async, flush_synced): + "Match for tlb_flush_stats event. Appends counts to the relevant array." + self.timestamps.append(timestamp) + self.flush_self.append(flush_self) + self.flush_async.append(flush_async) + self.flush_synced.append(flush_synced) + self.stats += 1 + + +def get_args(): + "Grab options" + parser = argparse.ArgumentParser() + parser.add_argument("--output", "-o", type=str, help="Render plot to file") + parser.add_argument("events", type=str, help='trace file read from') + parser.add_argument("tracefile", type=str, help='trace file read from') + return parser.parse_args() + +if __name__ == '__main__': + args = get_args() + + # Gather data from the trace + analyzer = CpuTLBFlushAnalyser() + simpletrace.process(args.events, args.tracefile, analyzer) + +# x = np.arange(analyzer.stats) + fself, = plt.plot(analyzer.timestamps, analyzer.flush_self, label="Self") + fasync, = plt.plot(analyzer.timestamps, analyzer.flush_async, label="Async") + fsynced, = plt.plot(analyzer.timestamps, analyzer.flush_synced, label="Synced") + + plt.legend(handles=[fself, fasync, fsynced]) + plt.xlabel("Execution Time") + plt.ylabel("Culmlative count") + + if args.output: + plt.savefig(args.output) + else: + plt.show()