11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.3 Packages • 83The display shows that only one branch of the if statement that formsthe body of p was taken so far. This is because only a non-negative argumenthas been supplied as an argument to p. To get complete coverage,a negative argument must also be supplied.> p( -1 );−2> showstat( p );p := proc(x)|Calls Seconds Words|PROC | 2 0.000 16|1 | 2 0.000 16| if x < 0 then2 | 1 0.000 0| 2*xelse3 | 1 0.000 0| 1+2*xend ifend procThe display shows that each statement in the body of p has beenreached.The profiling information is stored in an rtable assigned to a namethat is formed by concatenating the name TRACE with the name of theprocedure (the one used in the call to debugopts), separated by a slashcharacter /.> eval( ‘TRACE/p‘ );⎡⎢⎣2 0 162 0 161 0 01 0 0⎤⎥⎦The package illustrated in this section helps extend this functionalityto modules, and acts as an interface to the debugopts with the traceprocoption.The coverage package has two exports: profile and covered. Twoprivate procedures, rprofile and traced, are used as subroutines. Theyare stored in local variables of the underlying module of the package.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!