A couple of scripts, one in Python and the other in Perl, that demonstrate 'live mode' tracing. For each, the output of the perf event stream is fed continuously to the script, which continuously aggregates the data and reports the current results every 3 seconds, or at the optionally specified interval. After the current results are displayed, the aggregations are cleared and the cycle begins anew. To run the scripts, simply pipe the output of the 'perf trace record' step as input to the corresponding 'perf trace report' step, using '-' as the filename to -o and -i: $ perf trace record sctop -o - | perf trace report sctop -i - Also adds clear_term() utility functions to the Util.pm and Util.py utility modules, for use by any script to clear the screen. Signed-off-by: Tom Zanussi <tzanussi@gmail.com> Acked-by: Thomas Gleixner <tglx@linutronix.de> Cc: fweisbec@gmail.com Cc: rostedt@goodmis.org Cc: k-keiichi@bx.jp.nec.com Cc: acme@ghostprotocols.net LKML-Reference: <1270184365-8281-10-git-send-email-tzanussi@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
29 lines
686 B
Python
29 lines
686 B
Python
# Util.py - Python extension for perf trace, miscellaneous utility code
|
|
#
|
|
# Copyright (C) 2010 by Tom Zanussi <tzanussi@gmail.com>
|
|
#
|
|
# This software may be distributed under the terms of the GNU General
|
|
# Public License ("GPL") version 2 as published by the Free Software
|
|
# Foundation.
|
|
|
|
NSECS_PER_SEC = 1000000000
|
|
|
|
def avg(total, n):
|
|
return total / n
|
|
|
|
def nsecs(secs, nsecs):
|
|
return secs * NSECS_PER_SEC + nsecs
|
|
|
|
def nsecs_secs(nsecs):
|
|
return nsecs / NSECS_PER_SEC
|
|
|
|
def nsecs_nsecs(nsecs):
|
|
return nsecs % NSECS_PER_SEC
|
|
|
|
def nsecs_str(nsecs):
|
|
str = "%5u.%09u" % (nsecs_secs(nsecs), nsecs_nsecs(nsecs)),
|
|
return str
|
|
|
|
def clear_term():
|
|
print("\x1b[H\x1b[2J")
|