向报告添加定制计数器

可使用定制代码向性能报告添加定制计数器。运行测试后,将使用聚集缺省性能测试计数器(例如,字节和页面计数器)的相同方式来自动聚集定制计数器中的结果。定制计数器的聚集将从所有代理程序计算机合并得到。
注: 除非您将定制计数器放到 RunPages 或其他根元素下面,否则“添加/除去运行统计信息计数器”窗口将不包含定制计数器的信息。

通过以下代码,您可以添加定制计数器。运行测试后,可通过将定制计数器从结果拖到报告上或通过使用“添加/除去”向导来在报告上显示定制计数器。

package CustomCounter;

import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;

/**
 * @author unknown
 */
public class Class implements
		com.ibm.rational.test.lt.kernel.custom.ICustomCode2 {

	/**
	 * Instances of this will be created using the no-arg constructor.
	 */
		public Class() {
	}

	/**
	 	 * For javadoc of ICustomCode2 and ITestExecutionServices interfaces, select 'Help Contents' in the
	 	 * Help menu and select 'Extending Rational Performance Tester functionality' -> 'Extending test execution with custom code'
	 */
		public String exec(ITestExecutionServices tes, String[] args) {tes.getStatisticsManager().getStatTree().getDistribution(new String[]{"Custom Counter","MyTest","MyValue"})
				.submitDataPoint(Double.valueOf(Math.random()*100.).longValue());

		return null;
	}

}

反馈