@@ -21,10 +21,10 @@ static struct tr2_dst tr2dst_perf = { TR2_SYSENV_PERF, 0, 0, 0 };
2121 */
2222static int tr2env_perf_be_brief ;
2323
24- #define TR2FMT_PERF_FL_WIDTH (50 )
24+ #define TR2FMT_PERF_FL_WIDTH (28 )
2525#define TR2FMT_PERF_MAX_EVENT_NAME (12)
26- #define TR2FMT_PERF_REPO_WIDTH (4 )
27- #define TR2FMT_PERF_CATEGORY_WIDTH (10 )
26+ #define TR2FMT_PERF_REPO_WIDTH (3 )
27+ #define TR2FMT_PERF_CATEGORY_WIDTH (12 )
2828
2929#define TR2_DOTS_BUFFER_SIZE (100)
3030#define TR2_INDENT (2)
@@ -79,17 +79,36 @@ static void perf_fmt_prepare(const char *event_name,
7979
8080 if (!tr2env_perf_be_brief ) {
8181 struct tr2_tbuf tb_now ;
82+ size_t fl_end_col ;
8283
8384 tr2_tbuf_local_time (& tb_now );
8485 strbuf_addstr (buf , tb_now .buf );
8586 strbuf_addch (buf , ' ' );
8687
87- if (file && * file )
88- strbuf_addf (buf , "%s:%d " , file , line );
89- while (buf -> len < TR2FMT_PERF_FL_WIDTH )
88+ fl_end_col = buf -> len + TR2FMT_PERF_FL_WIDTH ;
89+
90+ if (file && * file ) {
91+ struct strbuf buf_fl = STRBUF_INIT ;
92+
93+ strbuf_addf (& buf_fl , "%s:%d" , file , line );
94+
95+ if (buf_fl .len <= TR2FMT_PERF_FL_WIDTH )
96+ strbuf_addbuf (buf , & buf_fl );
97+ else {
98+ size_t avail = TR2FMT_PERF_FL_WIDTH - 3 ;
99+ strbuf_addstr (buf , "..." );
100+ strbuf_add (buf ,
101+ & buf_fl .buf [buf_fl .len - avail ],
102+ avail );
103+ }
104+
105+ strbuf_release (& buf_fl );
106+ }
107+
108+ while (buf -> len < fl_end_col )
90109 strbuf_addch (buf , ' ' );
91110
92- strbuf_addstr (buf , "| " );
111+ strbuf_addstr (buf , " | " );
93112 }
94113
95114 strbuf_addf (buf , "d%d | " , tr2_sid_depth ());
@@ -102,7 +121,7 @@ static void perf_fmt_prepare(const char *event_name,
102121 strbuf_addf (buf , "r%d " , repo -> trace2_repo_id );
103122 while (buf -> len < len )
104123 strbuf_addch (buf , ' ' );
105- strbuf_addstr (buf , "| " );
124+ strbuf_addstr (buf , " | " );
106125
107126 if (p_us_elapsed_absolute )
108127 strbuf_addf (buf , "%9.6f | " ,
@@ -116,8 +135,8 @@ static void perf_fmt_prepare(const char *event_name,
116135 else
117136 strbuf_addf (buf , "%9s | " , " " );
118137
119- strbuf_addf (buf , "%-*s | " , TR2FMT_PERF_CATEGORY_WIDTH ,
120- (category ? category : "" ));
138+ strbuf_addf (buf , "%-*.* s | " , TR2FMT_PERF_CATEGORY_WIDTH ,
139+ TR2FMT_PERF_CATEGORY_WIDTH , (category ? category : "" ));
121140
122141 if (ctx -> nr_open_regions > 0 ) {
123142 int len_indent = TR2_INDENT_LENGTH (ctx );
0 commit comments