Skip to contentSkip to conversation

tools:perf:scripts:python:intel-pt-events del unusedvar

PATCH Superseded Alexander Pantyukhin 2 participants 3 messages Jan 6, 2023 – Jan 14, 2023 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools:perf:scripts:python:intel-pt-events del unusedvar

The event_attr is never used later, the var is ok be deleted. Additional code simplification is to substitute string slice comparison with "substring" function. This case no need to know the length specific words.

---
 tools/perf/scripts/python/intel-pt-events.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/scripts/python/intel-pt-events.py +2 -3
index 08862a2582f4..28d08e2fb7cd 100644
@@ -340,7 +340,6 @@ def print_srccode(comm, param_dict, sample, symbol, dso, with_insn):
 	print(start_str, src_str)
 
 def do_process_event(param_dict):
-	event_attr = param_dict["attr"]
 	sample	   = param_dict["sample"]
 	raw_buf	   = param_dict["raw_buf"]
 	comm	   = param_dict["comm"]
@@ -359,13 +358,13 @@ def do_process_event(param_dict):
 		print(glb_switch_str[cpu])
 		del glb_switch_str[cpu]
 
-	if name[0:12] == "instructions":
+	if name.startswith("instructions"):
 		if glb_src:
 			print_srccode(comm, param_dict, sample, symbol, dso, True)
 		else:
 			print_instructions_start(comm, sample)
 			print_common_ip(param_dict, sample, symbol, dso)
-	elif name[0:8] == "branches":
+	elif name.startswith("branches"):
 		if glb_src:
 			print_srccode(comm, param_dict, sample, symbol, dso, False)
 		else:
Signature · 1 line
2.25.1
reviewer
#1 lore raw
Quoted 15 lines · Alexander Pantyukhin

The event_attr is never used later, the var is ok be deleted. Additional code simplification is to substitute string slice comparison with "substring" function. This case no need to know the length specific words.

---
 tools/perf/scripts/python/intel-pt-events.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/scripts/python/intel-pt-events.py +0 -0
index 08862a2582f4..28d08e2fb7cd 100644

tools/perf/scripts/python/intel-pt-events.py def print_srccode(comm, param_dict, sample, symbol, dso, with_insn): · line 343

Quoted 4 lines
tools/perf/scripts/python/intel-pt-events.py +0 -1
@@ -340,7 +340,6 @@ def print_srccode(comm, param_dict, sample, symbol, dso, with_insn):
 	print(start_str, src_str)
 
 def do_process_event(param_dict):
-	event_attr = param_dict["attr"]

Should really be moved to the "Unused fields:" comment section a few lines below.

Quoted 19 lines
tools/perf/scripts/python/intel-pt-events.py +2 -2
 	sample	   = param_dict["sample"]
 	raw_buf	   = param_dict["raw_buf"]
 	comm	   = param_dict["comm"]
@@ -359,13 +358,13 @@ def do_process_event(param_dict):
 		print(glb_switch_str[cpu])
 		del glb_switch_str[cpu]
 
-	if name[0:12] == "instructions":
+	if name.startswith("instructions"):
 		if glb_src:
 			print_srccode(comm, param_dict, sample, symbol, dso, True)
 		else:
 			print_instructions_start(comm, sample)
 			print_common_ip(param_dict, sample, symbol, dso)
-	elif name[0:8] == "branches":
+	elif name.startswith("branches"):
 		if glb_src:
 			print_srccode(comm, param_dict, sample, symbol, dso, False)
 		else:
#2 lore raw

Hello!

Quoted 19 lines · Alexander Pantyukhin
Quoted 17 lines

The event_attr is never used later, the var is ok be deleted. Additional code simplification is to substitute string slice comparison with "substring" function. This case no need to know the length specific words.

---
 tools/perf/scripts/python/intel-pt-events.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/perf/scripts/python/intel-pt-events.py +0 -0
index 08862a2582f4..28d08e2fb7cd 100644
@@ -340,7 +340,6 @@ def print_srccode(comm, param_dict, sample, symbol, dso, with_insn):
      print(start_str, src_str)
 
Quoted 5 lines

tools/perf/scripts/python/intel-pt-events.py def print_srccode(comm, param_dict, sample, symbol, dso, with_insn): · line 343

Quoted 2 lines
tools/perf/scripts/python/intel-pt-events.py +0 -1
 def do_process_event(param_dict):
-     event_attr = param_dict["attr"]

Should really be moved to the "Unused fields:" comment section a few lines below.

Fixed in the patch v2.

Quoted 21 lines
Quoted 20 lines
tools/perf/scripts/python/intel-pt-events.py +2 -2
      sample     = param_dict["sample"]
      raw_buf    = param_dict["raw_buf"]
      comm       = param_dict["comm"]
@@ -359,13 +358,13 @@ def do_process_event(param_dict):
              print(glb_switch_str[cpu])
              del glb_switch_str[cpu]
 
-     if name[0:12] == "instructions":
+     if name.startswith("instructions"):
              if glb_src:
                      print_srccode(comm, param_dict, sample, symbol, dso, True)
              else:
                      print_instructions_start(comm, sample)
                      print_common_ip(param_dict, sample, symbol, dso)
-     elif name[0:8] == "branches":
+     elif name.startswith("branches"):
              if glb_src:
                      print_srccode(comm, param_dict, sample, symbol, dso, False)
              else: