Re: Re: [PEPr] Comment on Networking::Monitor

From: Date: Thu, 09 Dec 2004 23:08:18 +0000
Subject: Re: Re: [PEPr] Comment on Networking::Monitor
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-34994@lists.php.net to get a copy of this message
Hi Bertrand, Yes -- I did. They don't work recursively on the structure at hand, which is a non-associative array of associative arrays. Also, the conditions for what constitutes a true duplication are unique to the application, and unique to the flags being set by the end user. Sometimes host/service matching is enough to be a duplicate, sometimes the codes also have to match. Sometimes this is something you want to include in the returned array (depending on options), sometimes not. Finally, the non-duplicate values in the secondary array need to be marked as now having an OK state. So, there's a lot more going on than a classical array_diff, and handling that right in the loop is probably more efficient than using more generic functions and then going back over the arrays again (and again) to handle the special cases. The trick, I think, is making it clear what is happening at every stage, since there is a lot going on besides just calculating the difference. Hopefully the comments illustrate this well enough. Best, Robert Bertrand Mansion wrote:
Robert Peake wrote:
Hi Bertrand, Net_Monitor::stateDiff() does not operate at (N**2). It is actually quite efficient to the task it has to accomplish and the types of arrays it is comparing. If you have an idea for how to make this method more efficient, I would be happy to review your code and benchmarks.
Did you consider using array_diff, array_merge or array_diff_assoc or other array functions : <http://www.php.net/manual/en/function.array-diff-assoc.php> They might suit your needs and be a lot faster :) Bertrand Mansion Mamasam


« previous php.pear.dev (#34994) next »