11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

82 • Chapter 3: <strong>Programming</strong> with ModulesDesign You can write tests that exercise each part of the program toensure that the program:• Works correctly• Continues to work when it, or other programs on which it depends,change over time.It is important to be able to determine whether each statement in aprocedure is executed by some test case. The traceproc option of theMaple command debugopts provides that capability. It takes the name pof a procedure, using the syntaxdebugopts( ’traceproc’ = p );and instruments the procedure assigned to p for coverage profiling. Hereis an example.> p := proc( x )> if x < 0 then> 2 * x> else> 1 + 2 * x> end if> end proc:> debugopts( ’traceproc’ = p ):Once the procedure has been instrumented, each time it is executed,profiling information at the statement level is stored. To view the profilinginformation, use the procedure showstat.> p( 2 );5> showstat( p );p := proc(x)|Calls Seconds Words|PROC | 1 0.000 12|1 | 1 0.000 12| if x < 0 then2 | 0 0.000 0| 2*xelse3 | 1 0.000 0| 1+2*xend ifend proc

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

Saved successfully!

Ooh no, something went wrong!