From: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
To: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org, h.mitake@gmail.com,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH] perf: Make printing table easily
Date: Wed, 17 Mar 2010 16:59:00 +0900 [thread overview]
Message-ID: <4BA08BC4.1070605@dcl.info.waseda.ac.jp> (raw)
In-Reply-To: <4BA089C0.8090406@dcl.info.waseda.ac.jp>
On 03/17/10 16:50, Hitoshi Mitake wrote:
> 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);
>
Another suggestion:
If table_add_column() returns "column ID",
table_add_field() can specify tha column with it
and duplication of string can be reduced.
prev parent reply other threads:[~2010-03-17 7:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-08 7:55 [PATCH] perf: Make printing table easily Hitoshi Mitake
2010-03-11 12:51 ` Ingo Molnar
2010-03-11 14:06 ` Arnaldo Carvalho de Melo
2010-03-17 7:50 ` Hitoshi Mitake
2010-03-17 7:59 ` Hitoshi Mitake [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BA08BC4.1070605@dcl.info.waseda.ac.jp \
--to=mitake@dcl.info.waseda.ac.jp \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@infradead.org \
--cc=fweisbec@gmail.com \
--cc=h.mitake@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox