i965: Tidy shader time printing code by using printf's field widths.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 28 Mar 2013 07:18:46 +0000 (00:18 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 28 Mar 2013 18:46:44 +0000 (11:46 -0700)
We can use %-6s%-6s rather than manually counting characters, resulting
in much more readable code.

This necessitates a small secondary change: using "total fs16" and ""
now causes the "" string to be padded out to 6 characters, resulting in
too much whitespace.  Splitting it into "total" and "fs16" produces the
same output as before.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_program.c

index d7606e2cb70ca19484a71d4956a58ce42eeaab31..87986a952f35a144f6141478d81bf19416c95d3c 100644 (file)
@@ -280,15 +280,7 @@ static void
 print_shader_time_line(const char *stage, const char *name,
                        int shader_num, uint64_t time, uint64_t total)
 {
-   int namelen = printf("%s ", stage);
-
-   while (namelen++ < 6)
-      printf(" ");
-
-   namelen += printf("%s ", name);
-
-   while (namelen++ < 13)
-      printf(" ");
+   printf("%-6s%-6s", stage, name);
 
    if (shader_num != -1)
       printf("%4d: ", shader_num);
@@ -429,9 +421,9 @@ brw_report_shader_time(struct brw_context *brw)
    }
 
    printf("\n");
-   print_shader_time_line("total vs", "", -1, total_by_type[ST_VS], total);
-   print_shader_time_line("total fs8", "", -1, total_by_type[ST_FS8], total);
-   print_shader_time_line("total fs16", "", -1, total_by_type[ST_FS16], total);
+   print_shader_time_line("total", "vs", -1, total_by_type[ST_VS], total);
+   print_shader_time_line("total", "fs8", -1, total_by_type[ST_FS8], total);
+   print_shader_time_line("total", "fs16", -1, total_by_type[ST_FS16], total);
 }
 
 static void