lkml.org 
[lkml]   [2010]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v6] Add generic exponentially weighted moving average (EWMA) function
Date
On Sun November 14 2010 17:51:08 Stefan Richter wrote:
> >>> Why do ewma_init() and ewma_add() return their first argument? They
> >>> look to me like they can be straight-forward void functions.
> >>
> >> You are right, for ewma_init() it does not make sense.
> >>
> >> For ewma_add() I think it does. This has been discussed before (e.g.
> >> http://linux.derkeiler.com/Mailing-Lists/Kernel/2010-10/msg09124.html).
> >> Some people might want to get the value when they add a sample by using
> >> ewma_get(ewma_add(&ewma, val));
> >>
> > ewma_add(&ewma, val);
> > ewma_get(&ewma);
> >
> > is enough simpler and cleaner. I don't oppse this :)
>
> There are more candidate colors for the bike shed: :-)
> - an ewma_add_return could do what ewma_get(ewma_add(...)) is meant for,

I think this would be overkill. We're just talking about a return pointer...

> - or ewma_add itself could return the result.

The way I intend to use it, I will add samples much more often than I get a
value, so IMHO it makes sense to split it.

> BTW, isn't "get" more usually used as a prefix for these kinds of functions
> in kernel APIs? "get" as a suffix more often means "get a reference"
> alias increase reference count rather than "get the value".

Umm. I don't know and honstly I don't care. I think the API ewma_* is
consistent. If you have a good reason to change it please let me know,
otherwise i'd just leave it like it is now.

bruno


\
 
 \ /
  Last update: 2010-11-15 03:13    [W:0.086 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site