# This script filters the PERF traces based on the specified parameters and # measures the rate of the filtered traces. This can be used to measure # video encode/decode/preview frame rates. # # Fields in a PERF CSV line: # # $1 - time stamp # $2 - PID # $3 - address # $4 - component # $5-$10 - domains (AD, VD, ID, AE, VE, IE) # $11 - component type # $12 - operation # $13-... operation specific arguments: # Buffer: # $13 - sending|received|xfering # $14 - frame|buffer # $15 - from # $16 - to # $17 - size # $18 - address 1 # $19 - address 2 # Boundary: # $13 - hex # $14 - textual # initialize variables BEGIN { FS = ","; # reading a CSV file what = what ? what : "frame"; # what buffers are we looking at how = how ? how : "sending"; # what is the operation to = to ? to : ""; # who are the recipients of these buffers from = from ? from : ""; # who are the senders of these buffers # boundary - only log buffer traces in the steady state of this component boundary = boundary ? boundary : "****"; min = (size != "") ? (size) : (min != "") ? (min) : 1; # min size of buffers to watch max = (size != "") ? (size) : (max != "") ? (max) : 5e9; # max size of buffers to watch # Additional variables not set: # debug - debug flag # after - only measure frames after the specified # # who - who is logging these buffer transfers # get variable assignments from ARGV for (i=1; i 1) { print "who = ", who print "how = ", how print "what = ", what print "from = ", (from ? from : "UNDEFINED") print "to = ", (to ? to : "UNDEFINED") print "min = ", min print "max = ", max } # convert to decimal min = min + 0 max = max + 0 } # Check for non-CSV trace file /^= min) && ((0 + $17) <= max) { # debug if (debug) { print $0 } # increase the count from the boundary if (count == after) { delta = $1 - last; if (delta >= 2) { print "Warning: Found a pause of", delta, "seconds"; } else { x_no_pause += delta; xx_no_pause += delta * delta; N_no_pause++; } x += delta; xx += delta * delta; N++; } if (count < after) { count++; } last = $1; } # Check boundaries /Steady/ && $12 == "Boundary" && $4 == boundary { # debug if (debug) { print $0 } # start counting if starting steady state, skip counting if ending steady # state count = /started/ ? 0 : skip; } END { # calculate inverse (1/x) average and variance if (N) { x /= N; xx /= N; s = xx ? (x * x / xx) : 0; result = 1/x " fps (s=" s ") (from " N " data points)"; print "Rate is", result; if (N != N_no_pause) { if (N_no_pause) { x = x_no_pause / N_no_pause; xx = xx_no_pause / N_no_pause; s = xx ? (x * x / xx) : 1; result = 1/x " fps (s=" s ") (from " N " data points)"; print "(Adjusted rate without pauses is", result, ")"; } else { print "(Not enough data to calculate adjusted rate without pauses)"; } } } else { print "Error: Not enough data to calculate rate"; } }