Skip to contentSkip to conversation

perf script: Don't force less for non tty output with --xed

PATCH New Andi Kleen 1 participant 1 message May 22, 2020 perf events

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 perf script: Don't force less for non tty output with --xed

From: Andi Kleen <[email protected]>

--xed currently forces less. When piping the output to other scripts this can waste a lot of CPU time because less is rather slow. I've seen it using up a full core on its own in a pipeline. Only force less when the output is actually a terminal.

---
 tools/perf/builtin-script.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/builtin-script.c +4 -1
index 56d7bcd12671..c4c6a00e0341 100644
@@ -3286,7 +3286,10 @@ static int parse_xed(const struct option *opt __maybe_unused,
 		     const char *str __maybe_unused,
 		     int unset __maybe_unused)
 {
-	force_pager("xed -F insn: -A -64 | less");
+	if (isatty(1))
+		force_pager("xed -F insn: -A -64 | less");
+	else
+		force_pager("xed -F insn: -A -64");
 	return 0;
 }
 
Signature · 1 line
2.25.4