All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Zhbanov <i.zhbanov at samsung.com>
To: powertop@lists.01.org
Subject: Re: [Powertop] [RFC][PATCH 1/2] Adding report generator facility
Date: Tue, 09 Oct 2012 21:02:28 +0400	[thread overview]
Message-ID: <507458A4.8090403@samsung.com> (raw)
In-Reply-To: 20121008165743.GA21958@swordfish.datadirect.datadirectnet.com

[-- Attachment #1: Type: text/plain, Size: 2429 bytes --]

Hi Sergey,

Sergey Senozhatsky wrote:

> Hello,
>
> - can we please avoid code duplication? for example, both html and csv
> reporters contain identical implementations of
>
> clear_result()/get_result()/add*() and friends.

Done. Please check v2 patchset (after list moderator will approve those big letters).

> - I think null formatter could be a basic class with default
> implementation (null) of virtual functions, rather than separate
> implementation of basic formatter interface (abstract class).

The null formatter is needed only because the code that uses the report
facility is called even when the reports are not needed.

The function one_measurement() (which calls to other reporting functions) first
called from make_report() with 1 second parameter. And that report will be thrown
away. In the comments there is a note that this is to warm-up the system. I don't know
whether it is really needed.

After that make_report() produces real reports inside the loop by calling
the one_measurement() function.

Also one_measurement() is called from calibration code, and that code doesn't need
any reports too.

So we need to decide when to call reporting functions from one_measurement().
We could check the report_type there. But what type of report maker should we create
when we don't need the reports? HTML? CSV? Sounds no good.

Providing a flag inside the report maker whether we need to produce the reports
and check it upon entry to every method is no good too.

We could create report maker and provide it to the needed functions by pointer.
But what to provide when we need not report? NULL? Then we have to check for it
in every function. Lot's of unnecessary checks.

We could combine two mentioned approaches -- create report maker only when
we actually need to produce the report, and call report creating functions from
one_measurement() with non-NULL pointer to report (and pass it down to all
other functions that need it).

Then we could get rid of null report-maker. But now it is easier way to deal with
such usage of report facility.

What you think?

It is very hard to refactor this code.

-- 
Best regards,
Igor Zhbanov,
Expert Software Engineer,
phone: +7 (495) 797 25 00 ext 3806
e-mail: i.zhbanov(a)samsung.com

ASWG, Moscow R&D center, Samsung Electronics
12 Dvintsev street, building 1
127018, Moscow, Russian Federation


             reply	other threads:[~2012-10-09 17:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-09 17:02 Igor Zhbanov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-10-10 15:53 [Powertop] [RFC][PATCH 1/2] Adding report generator facility Chris Ferron
2012-10-10 15:39 Sergey Senozhatsky
2012-10-10 12:49 Igor Zhbanov
2012-10-09 19:31 Sergey Senozhatsky
2012-10-09 19:11 Sergey Senozhatsky
2012-10-09 19:03 Sergey Senozhatsky
2012-10-09 18:55 Sergey Senozhatsky
2012-10-09 17:25 Igor Zhbanov
2012-10-08 16:57 Sergey Senozhatsky
2012-10-05 10:15 Igor Zhbanov
2012-10-04 21:17 Sergey Senozhatsky
2012-10-04 21:07 Sergey Senozhatsky
2012-10-04 16:08 Ferron, Chris E
2012-10-03 17:05 Igor Zhbanov

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=507458A4.8090403@samsung.com \
    --to=powertop@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.