our crack dev team is working on a better example for the custom counter example, but in interim I was provided this more simpler example with caveat it works with 10.1 or later. You'll have to customize the report to show the custom counters.
-------
package customcode;
import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;
import com.ibm.rational.test.lt.kernel.services.stats.IStatisticsManager2;
import com.ibm.rational.test.lt.kernel.services.stats.IValueCounter;
/**
* L3 Support
*/
public class CustomCounters implements com.ibm.rational.test.lt.kernel.custom.ICustomCode2 {
/**
* Instances of this will be created using the no-arg constructor.
*/
public CustomCounters() {
}
/**
* This custom code reports two custom values, a "Hits" counter and a "RandomValue" measurement (0-14).
* When adding counters to a report, Both values will appear under Custom in the available counters:
*
* Custom
* CustomCount
* Hits
* CustomStat
* RandomValue
*
* This code will work with RPT 10.1 and later; it is not applicable to earlier releases.
**/
public String exec(ITestExecutionServices tes, String[] args) {
IStatisticsManager2 mgr = tes.getStatisticsManager2();
mgr.getCountCounter("Custom", "CustomCount", "Hits").increment();
IValueCounter value = mgr.getValueCounter("Custom", "CustomStat", "RandomValue");
value.addMeasurement(System.currentTimeMillis() % 15);
return null;
}
}
#SupportMigration#Support#RationalPeformanceTester