lkml.org 
[lkml]   [2010]   [Mar]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf: Make printing table easily
On 03/11/10 23:06, Arnaldo Carvalho de Melo wrote:
> Em Thu, Mar 11, 2010 at 01:51:26PM +0100, Ingo Molnar escreveu:
>>
>> * Hitoshi Mitake<mitake@dcl.info.waseda.ac.jp> wrote:
>>
>>> Hi,
>>>
>>> Making table of matrix by printf is painful work,
>>> but it can be found in perf here and there.
>>> So I'd like to propose semi-automation of making table.
>>> New files util/table.c provides stuffs for easy table printing.
>>
>> Looks quite reasonable in theory. I suspect it would be useful to
see a few
>> table printing places converted to this facility, to see the
simplification
>> factor in practice.
>
> I'm going thru the printing routines now to get them usable by TUI/GUIs,
> starting with a libnewt based browser integrating initially report and
> annotate, after I get the first patch in shape for merging I'll revisit
> this table class of yours :-)

Thanks Arnaldo!

But I noticed fatal weak point of table.c.

User of table.c can reduce the cost of specifying
format specifier for printf, but like this case:

table_add_fixed(t, "%p", SIZE_OF_ADDR);
if (some_cond1)
table_add_fixed(t, "%10d", sizeof(int));
if (some_cond2)
table_add_string(t, "%30s", 30);

table_printf() may produces a lot of if-branch like this:

if (some_cond1 && some_cond2)
table_printf(t, table_test, 2501, "one");
else if (!some_cond1 && some_cond2)
table_printf(t, table_test, "one");
else if (some_cond1 && !some_cond2)
table_printf(t, table_test, 2501);

It is not so good, as Ingo told, at least table of this style
is not useful in real world...

But, how about this style?

First, user declare column with name like this:
table_add_column(t, "num1", "%10d", sizeof(int));

Then, user can add values with name,
table_add_field(t, "num1", 2501);

Finally, flush stored column
table_flush_line(t);

This way will be good for making title of table.
How about this?

Thanks,
Hitoshi


\
 
 \ /
  Last update: 2010-03-17 08:53    [W:0.191 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site