in java/src/org/apache/qetest/xsl/PerfTestlet.java [75:247]
protected void testDatalet(StylesheetDatalet datalet, TransformWrapper transformWrapper)
throws Exception
{
// Setup: Save options from the datalet in convenience variables
int iterations = 5;
boolean runtimeGC = true;
long[] times = null;
// Read in necessary options from test.properties file.
try
{
iterations = Integer.parseInt(datalet.options.getProperty("iterations"));
}
catch (Exception e) { /* no-op, leave as default */ }
try
{
String gc = datalet.options.getProperty("runtimeGC");
if (gc != null)
runtimeGC = (Boolean.valueOf(gc)).booleanValue();
}
catch (Exception e) { /* no-op, leave as default */ }
// Setup: store various XalanC-like timing data in convenience variables
long warmup = 0L; // First transform. Used to load classes.
long singletransform = 0L; // Very first Preload end-to-end transform
long etoe = 0L; // First end-to-end transform during iterations
long avgetoe = 0L; // Average of end-to-end transforms during iterations
long parsexsl = 0L; // First stylesheet preprocess during iterations
long avgparsexsl = 0L; // Average of stylesheet preprocess during iterations
long unparsedxml = 0L; // First stylesheet process during iterations
long transxml = 0L; // Transform w/Stylesheet - NO OUTPUT
long transxmloutput = 0L; // Transform w/Stylesheet - OUTPUT
//logger.logMsg(Logger.TRACEMSG, "executing with: inputName=" + datalet.inputName
// + " xmlName=" + datalet.xmlName + " outputName=" + datalet.outputName
// + " goldName=" + datalet.goldName + " flavor=" + datalet.flavor
// + " iterations=" + iterations
// + " algorithim=" + getDescription());
//@todo make various logMemory calls optional
logMemory(runtimeGC, false);
// Measure(warmup): JVM warm up
times = transformWrapper.transform(datalet.xmlName, datalet.inputName,
datalet.outputName);
warmup = times[TransformWrapper.IDX_OVERALL];
logMemory(runtimeGC, false);
// Measure(singletransform): Very first Preload end-to-end transform
times = transformWrapper.transform(datalet.xmlName, datalet.inputName,
datalet.outputName);
singletransform = times[TransformWrapper.IDX_OVERALL];
logMemory(runtimeGC, false);
// Measure(parsexsl): once: first preprocess
times = transformWrapper.buildStylesheet(datalet.inputName);
parsexsl = times[TransformWrapper.IDX_OVERALL];
logMemory(runtimeGC, false);
// Measure(unparsedxml): once: first process
times = transformWrapper.transformWithStylesheet(datalet.xmlName, datalet.outputName);
unparsedxml = times[TransformWrapper.IDX_OVERALL];
logMemory(runtimeGC, false);
for (int ctr = 1; ctr <= iterations; ctr++)
{
// Measure(avgparsexsl): average preprocess
times = transformWrapper.buildStylesheet(datalet.inputName);
avgparsexsl += times[TransformWrapper.IDX_OVERALL];
logMemory(runtimeGC, false);
// Measure(avgunparsedxml): getTransformer + xmlRead + transform
times = transformWrapper.transformWithStylesheet(datalet.xmlName, datalet.outputName);
transxml += times[TransformWrapper.IDX_TRANSFORM];
logMemory(runtimeGC, false);
// Measure(avgunparsedxml): getTransformer + xmlRead + transform + resultWrite
times = transformWrapper.transformWithStylesheet(datalet.xmlName, datalet.outputName);
transxmloutput += times[TransformWrapper.IDX_OVERALL];
logMemory(runtimeGC, false);
}
// Measure(etoe): once: first full process
times = transformWrapper.transform(datalet.xmlName, datalet.inputName, datalet.outputName);
etoe = times[TransformWrapper.IDX_OVERALL];
logMemory(runtimeGC, false);
// Aggregate all specific timing data returned by TransformWrappers
// note that different flavors of wrappers will be able
// to report different kinds of times
// This data is separate from the XalanC-like data above
//@todo determine which data is best to store
long[] storedTimes = TransformWrapperHelper.getTimeArray();
long[] storedCounts = TransformWrapperHelper.getTimeArray();
for (int ctr = 1; ctr <= iterations; ctr++)
{
// Measure(avgetoe): average full process
times = transformWrapper.transform(datalet.xmlName, datalet.inputName, datalet.outputName);
avgetoe += times[TransformWrapper.IDX_OVERALL];
aggregateTimes(times, storedTimes, storedCounts);
logMemory(runtimeGC, false);
}
Hashtable attrs = new Hashtable();
// BOTH: Log all specific timing data returned by TransformWrappers
logAggregateTimes(attrs, storedTimes, storedCounts);
// ASLO: Log special XalanC-like performance element with our timing
// UniqRunid is an Id that our TestDriver normally sets
// with some unique code, so that results analysis
// stylesheets can compare different test runs
attrs.put("UniqRunid", datalet.options.getProperty("runId", "runId;none"));
// processor is the 'flavor' of processor we're testing
attrs.put("processor", transformWrapper.getDescription());
// idref is the individual filename
attrs.put("idref", (new File(datalet.inputName)).getName());
// inputName is the actual name we gave to the processor
attrs.put("inputName", datalet.inputName);
attrs.put("iterations", new Integer(iterations));
attrs.put("warmup", new Long(warmup));
attrs.put("singletransform", new Long(singletransform)); // Very first Preload end-to-end transform
attrs.put("etoe", new Long(etoe)); // First end-to-end transform during iterations
// Note that avgetoe should match logTimes()'s OVERALL value
attrs.put("avgetoe", new Long(avgetoe / iterations)); // Average of end-to-end transforms during iterations
attrs.put("parsexsl", new Long(parsexsl)); // First stylesheet preprocess during iterations
attrs.put("avgparsexsl", new Long(avgparsexsl / iterations)); // Average of stylesheet preprocess during iterations
attrs.put("unparsedxml", new Long(unparsedxml)); // First stylesheet process during iterations
attrs.put("transxml", new Long(transxml / iterations)); // Average of stylesheet process during iterations
// Additional metrics for data throughput
File fIn = new File(datalet.inputName);
long btIn = iterations * fIn.length();
attrs.put("BytesIn", new Long(btIn));
// Due to unknown reasons the output needs to be filtered through a FileInputStream to get it's size.
File fOut = new File(datalet.outputName);
FileInputStream fOutStrm = new FileInputStream(fOut);
int len = fOutStrm.available();
long btOut = iterations * fOut.length();
attrs.put("BytesOut", new Long(btOut));
fOutStrm.close();
// I've added additional measurments. DP calculated KBs as ((Ki+Ko)/2)/sec.
// I now calculate it with the following (Ki+K0)/sec
// Calculate TRANSFORM thruput (Kb/sec). Based on DataPower; does NOT file I/O
double KBtdp = (double)(1000 * (btIn + btOut)) / (double)(1024 * 2 * transxml);
DecimalFormat fmt = new DecimalFormat("####.##");
StringBuffer x = new StringBuffer( fmt.format(KBtdp));
attrs.put("KBtdp", x);
// Calculate OVERALL thruput (Kb/sec). Based on DataPower; does include file I/O
double KBtsdp = (double)(1000 * (btIn + btOut)) / (double)(1024 * 2 * transxmloutput);
//DecimalFormat fmt = new DecimalFormat("####.##");
x = new StringBuffer(fmt.format(KBtsdp));
attrs.put("KBtsdp", x);
// Calculate TRANSFORM thruput (Kb/sec). Based on ped; does NOT file I/O
double KBtPD = (double)(1000 * (btIn + btOut)) / (double)(1024 * transxml);
//DecimalFormat fmt = new DecimalFormat("####.##");
x = new StringBuffer(fmt.format(KBtPD));
attrs.put("KBtPD", x);
// Calculate OVERALL thruput (Kb/sec). Based on ped; does include file I/O
double KBtsPD = (double)(1000 * (btIn + btOut)) / (double)(1024 * transxmloutput);
//DecimalFormat fmt = new DecimalFormat("####.##");
x = new StringBuffer(fmt.format(KBtsPD));
attrs.put("KBtsPD", x);
logger.logElement(Logger.STATUSMSG, "perf", attrs, fIn.getName());
}