[xdebug-general] Re: Code-coverage - clear previously collected data?

From: Andrew Cherry <andrew[@]xyncro.com>
Date: Thu, 21 Oct 2004 14:54:47 +0100

Thanks for the clarification Derick, I've added that to the tracker as
requested. If I had more time I'd submit a patch, but I'm a bit busy these
days!

For anyone that needs to work around this for now, here a quick and dirty
function that'll subtract the results of one coverage from another, thereby
leaving you with only the stuff that's happened since you took the first
snapshot (if that makes any sense at all). It's not wildly beautiful code,
but it's reasonably swift, and gets the job done! Might come in handy for
someone.

        public static function subtractCodeCoverage($preCov, $postCov){
            foreach($postCov as $postFile => $postArray){
                if(array_key_exists($postFile, $preCov)){
                    foreach($postArray as $postLine => $postCount){
                        if(array_key_exists($postLine, $preCov[$postFile])){
                            $postCov[$postFile][$postLine] = ($postCount -
$preCov[$postFile][$postLine]);
                            if($postCov[$postFile][$postLine] == 0){
                                unset($postCov[$postFile][$postLine]);
                            }
                        }
                    }
                    if(count($postCov[$postFile]) == 0){
                        unset($postCov[$postFile]);
                    }
                }
            }
            return $postCov;
        }

It's a bit more verbose than it needs to be, so I can remember what it does
;)

Andrew

-----Original Message-----
From: Derick Rethans [mailto:derick[@]xdebug.org]
Sent: 21 October 2004 08:57
To: Andrew Cherry
Subject: Re: [xdebug-general] Code-coverage - clear previously collected
data?

On Tue, 19 Oct 2004, Andrew Cherry wrote:

> Hi everyone, first post to this list so... I'm experimenting with the code
> coverage info in 2.0 Beta 1 (under windows), and I'm running into a slight
> problem, in that I can't see any way of clearing the results internal to
> xdebug before starting a new coverage block. This obviously means that the
> data is cumulative, and I end up with rather odd data for coverages, with
> the number of times a function has been called being the total since
> instantiation, rather than coverage_start. This would be fine for most
> purposes perhaps, but is there a way around it? An undocumented clear
> function perhaps?

There is at the moment no function for this. Can you file a feature
request at http://bugs.xdebug.org so that I don't forget to add this
before releasing 2.0?

(Please reply to the mailinglist when replying)

regards,
Derick

-- 
Xdebug | http://xdebug.org | xdebug-general@lists.xdebug.org
Received on Thu Oct 21 2004 - 15:54:52 BST

This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST