Skip to content

Commit

Permalink
Replace tabs with 8-width spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhwi committed May 16, 2018
1 parent a9645fd commit a256cbd
Show file tree
Hide file tree
Showing 10 changed files with 11,154 additions and 11,154 deletions.
6 changes: 3 additions & 3 deletions event_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
def get_cpustr():
cpuinfo = os.getenv("CPUINFO")
if cpuinfo is None:
cpuinfo = '/proc/cpuinfo'
cpuinfo = '/proc/cpuinfo'
f = open(cpuinfo, 'r')
cpu = [None, None, None]
for j in f:
Expand Down Expand Up @@ -115,7 +115,7 @@ def download(match, key=None, link=True):
continue
cpu = sanitize(cpu, allowed_chars)
url = urlpath + name
fn = "%s-%s.json" % (cpu, sanitize(type, allowed_chars))
fn = "%s-%s.json" % (cpu, sanitize(type, allowed_chars))
try:
os.remove(os.path.join(dir, fn))
except OSError:
Expand Down Expand Up @@ -178,7 +178,7 @@ def eventlist_name(name=None, key="core"):
sys.exit(0)
d = getdir()
if args.all:
found = download('*', link=args.link)
found = download('*', link=args.link)
elif len(args.cpus) == 0:
found = download_current(link=args.link)
else:
Expand Down
69 changes: 34 additions & 35 deletions parser/perfdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# check size in all cases (or use optional+tunnel)
# tracing support
# processor trace (aux) data and extra info headers
#
#

from construct import *

Expand Down Expand Up @@ -51,8 +51,8 @@ def sample_id():
UNInt32("res")))),
If(lambda ctx: sample_type(ctx).identifier,
UNInt64("identifier2")))))
def fork_exit(name):

def fork_exit(name):
return Struct(name,
SNInt32("pid"),
SNInt32("ppid"),
Expand Down Expand Up @@ -131,7 +131,7 @@ def event():
Array(lambda ctx: hweight64(ctx),
UNInt64("reg")))),
If(lambda ctx: sample_type(ctx).stack_user,
Struct("stack_user",
Struct("stack_user",
UNInt64("size"),
Bytes("data", lambda ctx: ctx.size),
UNInt64("dyn_size"))),
Expand Down Expand Up @@ -163,7 +163,7 @@ def has_sample_id_all(ctx):
return attr.sample_id_all
return False

# when sample_id_all is not supported, we may
# when sample_id_all is not supported, we may
# not look up the right one (perf.data limitation)
def lookup_event_attr(ctx):
if "end_id" in ctx and ctx.end_id:
Expand All @@ -179,22 +179,22 @@ def lookup_event_attr(ctx):
def perf_event_header():
return Embedded(Struct(None,
Enum(UNInt32("type"),
MMAP = 1,
LOST = 2,
COMM = 3,
EXIT = 4,
THROTTLE = 5,
UNTHROTTLE = 6,
FORK = 7,
READ = 8,
SAMPLE = 9,
MMAP2 = 10,
TRACING_DATA = 66,
FINISHED_ROUND = 68,
ID_INDEX = 69,
AUXTRACE_INFO = 70,
AUXTRACE = 71,
AUXTRACE_ERROR = 72),
MMAP = 1,
LOST = 2,
COMM = 3,
EXIT = 4,
THROTTLE = 5,
UNTHROTTLE = 6,
FORK = 7,
READ = 8,
SAMPLE = 9,
MMAP2 = 10,
TRACING_DATA = 66,
FINISHED_ROUND = 68,
ID_INDEX = 69,
AUXTRACE_INFO = 70,
AUXTRACE = 71,
AUXTRACE_ERROR = 72),
Embedded(BitStruct(None,
Padding(1),
Enum(BitField("cpumode", 7),
Expand All @@ -204,7 +204,7 @@ def perf_event_header():
HYPERVISOR = 3,
GUEST_KERNEL = 4,
GUEST_USER = 5),

Flag("ext_reserved"),
Flag("exact_ip"),
Flag("mmap_data"),
Expand All @@ -227,8 +227,8 @@ def mmap():
Anchor("end_of_filename"),
# hack for now. this shouldn't be needed.
If(lambda ctx: True, # XXX
Embedded(Pointer(lambda ctx:
ctx.size + ctx.start -
Embedded(Pointer(lambda ctx:
ctx.size + ctx.start -
sample_id_size(ctx),
sample_id()))))
def mmap2():
Expand Down Expand Up @@ -266,7 +266,7 @@ def read_format():
Array(lambda ctx: ctx.nr,
Struct("val",
UNInt64("value"),
If(lambda ctx:
If(lambda ctx:
read_flags(ctx).id,
UNInt64("id2")))))),
If(lambda ctx: not read_flags(ctx).group,
Expand Down Expand Up @@ -307,8 +307,8 @@ def perf_event():
sample_id())),
"SAMPLE": event()
}),
Anchor("end"),
Padding(lambda ctx:
Anchor("end"),
Padding(lambda ctx:
ctx.size - (ctx.end - ctx.start)))

def perf_event_seq(attr):
Expand All @@ -317,7 +317,7 @@ def perf_event_seq(attr):
perf_event_attr_sizes = (64, 72, 80, 96, 104)

perf_event_attr = Struct("perf_event_attr",
Anchor("start"),
Anchor("start"),
Enum(UNInt32("type"),
HARDWARE = 0,
SOFTWARE = 1,
Expand Down Expand Up @@ -365,9 +365,9 @@ def perf_event_seq(attr):
Embedded(BitStruct(None,
Flag("disabled"),
Flag("inherit"),
Flag("pinned"),
Flag("exclusive"),
Flag("exclude_user"),
Flag("pinned"),
Flag("exclusive"),
Flag("exclude_user"),
Flag("exclude_kernel"),
Flag("exclude_hv"),
Flag("exclude_idle"),
Expand Down Expand Up @@ -468,7 +468,7 @@ def pmu_mappings():
return PrefixedArray(Struct("pmu",
UNInt32("type"),
str_with_len("name")),
UNInt32("nr"))
UNInt32("nr"))

def event_desc():
return Struct("event_desc",
Expand All @@ -489,7 +489,7 @@ def perf_features():
perf_file_section("tracing_data",
Pass)),
If(lambda ctx: ctx._.build_id,
section_adapter("build_id",
section_adapter("build_id",
GreedyRange(build_id()))),
feature_string("hostname"),
feature_string("osrelease"),
Expand All @@ -516,7 +516,7 @@ def perf_features():
Struct("cpu_topology",
string_list("cores"),
string_list("threads")))),
If(lambda ctx: ctx._.numa_topology,
If(lambda ctx: ctx._.numa_topology,
perf_file_section("numa_topology",
numa_topology())),
# not implemented in perf
Expand Down Expand Up @@ -609,4 +609,3 @@ def get_events(h):
h = perf_file.parse_stream(f)
print h
#print get_events(h)

12 changes: 6 additions & 6 deletions parser/perfpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def getid(self, id):
return self.ids[id]

def __getitem__(self, id):
return self.ids[id]
return self.ids[id]

cpumodes = {
'UNKNOWN': (0, 0, 0),
Expand Down Expand Up @@ -121,9 +121,9 @@ def samples_to_df(h, need_line):
continue

mm.update_sample(j)
def add(k, i):
data[k].append(i)
used[k] += 1
def add(k, i):
data[k].append(i)
used[k] += 1

filename, mmap_base, foffset = mm.resolve(j.pid, j.ip)
if filename == "[kernel.kallsyms]_text":
Expand Down Expand Up @@ -173,12 +173,12 @@ def read_samples(fn, need_line=True):
import sys

args = argparse.ArgumentParser()
args.add_argument('file', nargs='?', help='perf.data file to read',
args.add_argument('file', nargs='?', help='perf.data file to read',
default='perf.data')
args.add_argument('--repl', action='store_true',
help='start python shell with data')
args.add_argument('--ipython', action='store_true',
help='start ipython shell with data')
help='start ipython shell with data')
p = args.parse_args()
df, _, _ = read_samples(p.file)
if p.repl:
Expand Down
8 changes: 4 additions & 4 deletions tl_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ def __init__(self, known_cpus):
self.cputosocket = {}
self.allcpus = []
self.name = ""
cpuinfo = os.getenv("CPUINFO")
if cpuinfo is None:
cpuinfo = "/proc/cpuinfo"
with open(cpuinfo, "r") as f:
cpuinfo = os.getenv("CPUINFO")
if cpuinfo is None:
cpuinfo = "/proc/cpuinfo"
with open(cpuinfo, "r") as f:
ok = 0
for l in f:
n = l.split()
Expand Down
2 changes: 1 addition & 1 deletion tl_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def print_header(self, area, hdr):
# desc Object description
# sample Sample Objects (string)
# vs Statistics object
# bn marker for bottleneck
# bn marker for bottleneck
# Example:
# C0 BE Backend_Bound: 62.00 %
def show(self, timestamp, title, area, hdr, val, remark, desc, sample, valstat, bn):
Expand Down
Loading

0 comments on commit a256cbd

Please sign in to comment.