Skip to content

Commit

Permalink
Fix etwpmc_parser.py to take input filename
Browse files Browse the repository at this point in the history
This change removes the hardcoded input filename from etwpmc_parser.py
and also adds a usage message that is printed if no arguments are
specified.
  • Loading branch information
Bruce Dawson committed Nov 24, 2016
1 parent 7a3c19a commit ddd4c89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions LabScripts/ETWPMCDemo/etwpmc_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,17 @@

import sys

l = open("pmc_counters_test.txt").readlines()
if len(sys.argv) <= 1:
print 'Usage: %s xperfoutput [processname]' % sys.argv[0]
print 'The first parameter is the name of a file containing the results'
print 'of "xperf -i trace.etl". The second (optional) parameter is a'
print 'process name substring filter used to restrict which results are'
print 'shown - only processes that match are displayed.'
sys.exit(0)

xperfoutputfilename = sys.argv[1]

l = open(xperfoutputfilename).readlines()

# Scan through the counter data looking for Pmc and CSwitch records.
# If adjacent records are found that contain Pmc and CSwitch data then
Expand Down Expand Up @@ -131,5 +141,6 @@
for process in countersByProcess.keys():
totals = countersByProcess[process]
if totals[0] > 100000: # Arbitrary filtering
if len(sys.argv) == 1 or process.lower().count(sys.argv[1].lower()) > 0:
# Filter to the specific process substring if requested.
if len(sys.argv) == 2 or process.lower().count(sys.argv[2].lower()) > 0:
print "%43s: %5.2f%%, %s, %d context switches, time: %d" % (process, totals[0] * 100.0 / totals[1], totals, contextSwitchesByProcess[process], cpuTimeByProcess[process])
2 changes: 1 addition & 1 deletion LabScripts/ETWPMCDemo/etwpmc_record.bat
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ tracelog.exe -start pmc_counters -f pmc_counter_test.etl -eflag CSWITCH+PROC_THR
xperf -stop pmc_counters >nul
xperf -merge pmc_counter_test.etl pmc_counters_test_merged.etl
xperf -i pmc_counters_test_merged.etl -o pmc_counters_test.txt
python etwpmc_parser.py ConditionalCount
python etwpmc_parser.py pmc_counters_test.txt ConditionalCount

0 comments on commit ddd4c89

Please sign in to comment.