Thread (23 messages) 23 messages, 2 authors, 2017-04-19

Re: [PATCH v4 5/5] perf report: Show branch type in callchain entry

From: Jin, Yao <hidden>
Date: 2017-04-19 00:32:33
Also in: lkml


On 4/19/2017 2:53 AM, Jiri Olsa wrote:
On Wed, Apr 12, 2017 at 06:21:06AM +0800, Jin Yao wrote:

SNIP
quoted
  static int counts_str_build(char *bf, int bfsize,
  			     u64 branch_count, u64 predicted_count,
  			     u64 abort_count, u64 cycles_count,
-			     u64 iter_count, u64 samples_count)
+			     u64 iter_count, u64 samples_count,
+			     struct branch_type_stat *brtype_stat)
  {
-	double predicted_percent = 0.0;
-	const char *null_str = "";
-	char iter_str[32];
-	char cycle_str[32];
-	char *istr, *cstr;
  	u64 cycles;
+	int printed, i = 0;
  
  	if (branch_count == 0)
  		return scnprintf(bf, bfsize, " (calltrace)");
  
+	printed = branch_type_str(brtype_stat, bf, bfsize);
+	if (printed)
+		i++;
+
  	cycles = cycles_count / branch_count;
+	if (cycles) {
+		if (i++)
+			printed += scnprintf(bf + printed, bfsize - printed,
+				" cycles:%" PRId64 "", cycles);
+		else
+			printed += scnprintf(bf + printed, bfsize - printed,
+				" (cycles:%" PRId64 "", cycles);
+	}
  
  	if (iter_count && samples_count) {
-		if (cycles > 0)
-			scnprintf(iter_str, sizeof(iter_str),
-				 " iterations:%" PRId64 "",
-				 iter_count / samples_count);
+		if (i++)
+			printed += scnprintf(bf + printed, bfsize - printed,
+				" iterations:%" PRId64 "",
+				iter_count / samples_count);
  		else
-			scnprintf(iter_str, sizeof(iter_str),
-				 "iterations:%" PRId64 "",
-				 iter_count / samples_count);
-		istr = iter_str;
could you please put the change from using iter_str
to bf into separate patch before the actual branch
display change?

it's hard to see if anything is broken ;-)

thanks,
jirka
Got it, I will separate the patches.

Thanks
Jin Yao
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help