Next: , Previous: SIn_Array Overview, Up: SIn Array Object


7.2.2 SIn Array Example

The code below shows how to use a SIn_Array object to collect the number of times each branch executes.

     // Structure to store in SIn_Array
     //
     struct Diff_SIn_Info {int correct_count; int exe_count; };
     
     // Declare SIn_Array
     //
     SIn_Array<Diff_SIn_Info> sin_info;
     
     // This routine called for each CTI
     //
     void at_cti_commit(EZ_Profile_Diff *ezd, DIn *din)
     {
       Diff_SIn_Info* const si = ezd->sin_info[din];
       si->exe_count++;
     }
     
     // This routine called at end of simulation.
     //
     void at_simulation_complete(EZ_Profile_Diff *ezd)
     {
       double total_exec = 0;
       for( int ii; sin_info.iterate(ii); )
         {
           Diff_SIn_Info* const si = sin_info[ii];
           total_exec += si->exe_count;
         }
     }