diff mbox series

[PATH,i-g-t,12/13] media-bench: Write out trace files directly.

Message ID 20180905134939.2942-13-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Tracing & workload simulation misc patches | expand

Commit Message

Tvrtko Ursulin Sept. 5, 2018, 1:49 p.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Instead of relying on shell redirection.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 scripts/media-bench.pl | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/scripts/media-bench.pl b/scripts/media-bench.pl
index 9bf8c8789fe2..77e75c78b113 100755
--- a/scripts/media-bench.pl
+++ b/scripts/media-bench.pl
@@ -162,6 +162,21 @@  sub run_workload
 	return ($time, $wps);
 }
 
+sub dump_cmd
+{
+	my ($cmd, $file) = @_;
+
+	show_cmd("$cmd > $file");
+
+	open FOUT, '>', $file or die;
+	open TIN, "$cmd |" or die;
+	while (<TIN>) {
+		print FOUT $_;
+	}
+	close TIN;
+	close FOUT;
+}
+
 sub trace_workload
 {
 	my ($wrk, $b, $r, $c) = @_;
@@ -212,15 +227,12 @@  sub trace_workload
 	$b =~ s/[ <>]/_/g;
 	$file = "${wrk}_${b}_-r${r}_-c${c}";
 
-	$cmd = "perf script > ${file}.trace";
-	show_cmd($cmd);
-	system($cmd) == 0 or die;
+	dump_cmd('perf script', "${file}.trace");
 
 	$cmd = "perf script | $tracepl --html -x ctxsave -s -c ";
 	$cmd .= join ' ', map("-i $_", @skip_engine);
-	$cmd .= " > ${file}.html";
-	show_cmd($cmd);
-	system($cmd) == 0 or die;
+
+	dump_cmd($cmd, "${file}.html");
 
 	return \%engines;
 }