將自訂計數器新增至報告

您可以利用自訂程式碼將自訂計數器新增至效能報告。執行測試之後,來自自訂計數器的結果會以預設效能測試計數器的相同方式自動聚集(例如,位元組及頁面計數器)。自訂計數器的聚集是結合自所有代理電腦。
註: 除非您將自訂計數器放在 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;
	}

}

意見