Date: Tue, 14 Feb 2012 18:51:21 +0000 (UTC) From: "George V. Neville-Neil" <gnn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r231698 - head/tools/test/hwpmc Message-ID: <201202141851.q1EIpLPX012834@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gnn Date: Tue Feb 14 18:51:21 2012 New Revision: 231698 URL: http://svn.freebsd.org/changeset/base/231698 Log: Add options for program (-p) and to turn off waiting (-w) which is now on by default. The default is to wait after each counter is tested. Since the prompt would go to stdout you won't see it if you're redirecting the output of the executed sub-program to /dev/null, so just press return to continue or Ctrl-D to stop. Modified: head/tools/test/hwpmc/pmctest.py Modified: head/tools/test/hwpmc/pmctest.py ============================================================================== --- head/tools/test/hwpmc/pmctest.py Tue Feb 14 18:00:37 2012 (r231697) +++ head/tools/test/hwpmc/pmctest.py Tue Feb 14 18:51:21 2012 (r231698) @@ -38,10 +38,14 @@ # # To use: # -# pmctest.py ls > /dev/null +# pmctest.py -p ls > /dev/null # # This should result in ls being run with every available counter # and the system should neither lock up nor panic. +# +# The default is to wait after each counter is tested. Since the +# prompt would go to stdout you won't see it, just press return +# to continue or Ctrl-D to stop. import sys import subprocess @@ -53,10 +57,15 @@ notcounter = ["IAF", "IAP", "TSC", "UNC" def main(): - if (len(sys.argv) != 2): - print ("usage: pmctest.py program") + from optparse import OptionParser + + parser = OptionParser() + parser.add_option("-p", "--program", dest="program", + help="program to execute") + parser.add_option("-w", "--wait", action="store_true", dest="wait", + default=True, help="wait after each execution") - program = sys.argv[1] + (options, args) = parser.parse_args() p = subprocess.Popen(["pmccontrol", "-L"], stdout=PIPE) counters = p.communicate()[0] @@ -68,9 +77,15 @@ def main(): for counter in counters.split(): if counter in notcounter: continue - p = subprocess.Popen(["pmcstat", "-p", counter, program], stdout=PIPE) + p = subprocess.Popen(["pmcstat", "-p", counter, options.program], + stdout=PIPE) result = p.communicate()[0] print result + if (options.wait == True): + try: + value = raw_input("next?") + except EOFError: + sys.exit() # The canonical way to make a python module into a script. # Remove if unnecessary.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202141851.q1EIpLPX012834>