History

perf: net_dropmonitor: Do not assume ordering of dictionaries

The sort order of dictionaries in Python is undocumented. Use tuples instead, which are documented to be lexically ordered.

Ben Hutchings committed 13 years ago

Commit 326017c1 parent 5a1e99d1 file · +4 −4Browse files

Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all

Unified · Split

tools/perf/scripts/python/net_dropmonitor.py+4−4
@@ -32,7 +32,7 @@ def get_kallsyms_table(): · 31 unmodified lines
3232 j = j +1
3333 if ((j % 100) == 0):
3434 print "\r" + str(j) + "/" + str(linecount),
35− kallsyms.append({ 'loc': loc, 'name' : name})
35+ kallsyms.append((loc, name))
3636
3737 print "\r" + str(j) + "/" + str(linecount)
3838 kallsyms.sort()
@@ -40,9 +40,9 @@ def get_kallsyms_table(): · 1 unmodified line
4040
4141 def get_sym(sloc):
4242 loc = int(sloc)
43− for i in kallsyms[::-1]:
44− if loc >= i['loc']:
45− return (i['name'], loc - i['loc'])
43+ for symloc, name in kallsyms[::-1]:
44+ if loc >= symloc:
45+ return (name, loc - symloc)
4646 return (None, 0)
4747
4848 def print_drop_table():