pauldick 01/05/23 08:14:56
Modified: c/Tests/PerfT perft.cpp
Log:
Latest revisions to use Transformer
Revision Changes Path
1.3 +190 -273 xml-xalan/c/Tests/PerfT/perft.cpp
Index: perft.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/Tests/PerfT/perft.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- perft.cpp 2001/05/17 19:30:51 1.2
+++ perft.cpp 2001/05/23 15:14:52 1.3
@@ -84,7 +84,7 @@
#if defined(XALAN_NO_NAMESPACES)
typedef map<XalanDOMString, XalanDOMString, less<XalanDOMString> >
Hashtable;
#else
- typedef std::map<XalanDOMString, XalanDOMString> Hashtable;
+ typedef std::map<XalanDOMString, XalanDOMString> Hashtable;
#endif
// This is here for memory leak testing.
@@ -95,10 +95,7 @@
const char* const excludeStylesheets[] =
{
- //"basic-all_well.xsl",
"large-evans_large.xsl",
- //"sort-cem-big.xsl",
- //"large-cem10k.xsl",
0
};
@@ -117,31 +114,6 @@
return false;
}
-inline StylesheetRoot*
-processStylesheet(
- const XalanDOMString& theFileName,
- XSLTProcessor&
theProcessor,
- StylesheetConstructionContext& theConstructionContext)
-{
- const XSLTInputSource theInputSource(c_wstr(theFileName));
-
- return theProcessor.processStylesheet(theInputSource,
theConstructionContext);
-}
-
-
-
-inline XalanNode*
-parseSourceDocument(
- const XalanDOMString& theFileName,
- XSLTProcessor& theProcessor)
-{
- const XSLTInputSource theInputSource(c_wstr(theFileName));
-
- return theProcessor.getSourceTreeFromInput(theInputSource);
-}
-
-
-
inline double
calculateElapsedTime(
clock_t theStartTime,
@@ -156,79 +128,12 @@
clock_t accTime,
long theIterationCount)
{
- assert(theIterationCount > 0);
+ assert(theIterationCount > 1);
return double(accTime) / theIterationCount;
}
-inline double
-calculateAverageElapsedTime(
- clock_t theStartTime,
- clock_t theEndTime,
- long theIterationCount)
-{
- assert(theIterationCount > 0);
-
- return calculateElapsedTime(theStartTime, theEndTime) /
theIterationCount;
-}
-
-inline clock_t
-transformWUnparsedSource(const XalanDOMString& theFileName,
- XSLTProcessor& theProcessor,
- const StylesheetRoot* theStylesheetRoot,
- XSLTResultTarget& theResults,
- StylesheetExecutionContextDefault&
theExecutionContext)
-{
- const XSLTInputSource csSourceXML(c_wstr(theFileName)); //
Creates source document
- theProcessor.setStylesheetRoot(theStylesheetRoot);
-
- const clock_t startTime = clock();
- theProcessor.process(csSourceXML, theResults, theExecutionContext);
- const clock_t endTime = clock();
-
- return endTime - startTime;
-
-}
-
-inline clock_t
-transformWParsedSource(XalanNode* theParsedSource,
- XSLTProcessor& theProcessor,
- const StylesheetRoot* theStylesheetRoot,
- XSLTResultTarget& theResults,
- StylesheetExecutionContextDefault&
theExecutionContext)
-{
- // Put the parsed document into an XSLTInputSource,
- // and set stylesheet root in the processor
- const XSLTInputSource csSourceDocument(theParsedSource);
- theProcessor.setStylesheetRoot(theStylesheetRoot);
-
- const clock_t startTime = clock();
- theProcessor.process(csSourceDocument, theResults, theExecutionContext);
- const clock_t endTime = clock();
-
- return endTime - startTime;
-}
-inline long
-eTOeTransform(const XSLTInputSource& inputSource,
- const XSLTInputSource& stylesheetSource,
- XSLTResultTarget& outputTarget,
- StylesheetConstructionContext& constructionContext,
- StylesheetExecutionContext&
executionContext,
- XSLTProcessor&
theProcessor)
-{
- const clock_t startTime=clock();
- theProcessor.process(inputSource,
- stylesheetSource,
- outputTarget,
- constructionContext,
- executionContext);
- const clock_t endTime=clock();
-
- return endTime - startTime;
-}
-
-
void
printArgOptions()
{
@@ -369,223 +274,235 @@
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
#endif
-
- Hashtable runAttrs; // Attribute list for perfdata element
- long iterCount = 5; // Default number of iterations
- bool skip = true; // Default will skip long tests
- XalanDOMString category; // Test all of base dir by default
- XalanDOMString baseDir;
- XalanDOMString outputRoot;
+ HarnessInit xmlPlatformUtils;
+ XalanTransformer::initialize();
- FileUtility futil;
-
- if (getParams(argc, argv, futil, baseDir, outputRoot, category, skip,
iterCount) == true)
{
- //
- // Call the static initializers for xerces and xalan, and
create a transformer
- //
- HarnessInit xmlPlatformUtils;
- XalanTransformer::initialize();
- XalanTransformer xalan;
-
- // Generate Unique Run id and processor info
- const XalanDOMString UniqRunid = futil.GenerateUniqRunid();
+ Hashtable runAttrs; // Attribute list for perfdata
element
+ long iterCount = 5; // Default number of iterations
+ bool skip = true; // Default will skip long tests
+ XalanDOMString category; // Test all of base dir by
default
+ XalanDOMString baseDir;
+ XalanDOMString outputRoot;
- // Defined basic constants for file manipulation and open
results file
- const XalanDOMString resultFilePrefix(XalanDOMString("cpp"));
- const XalanDOMString resultsFile(outputRoot + resultFilePrefix
+ UniqRunid + XMLSuffix);
+ FileUtility futil;
+ if (getParams(argc, argv, futil, baseDir, outputRoot, category,
skip, iterCount) == true)
+ {
+ //
+ // Call the static initializers for xerces and xalan,
and create a transformer
+ //
+ XalanTransformer xalan;
- XMLFileReporter logFile(resultsFile);
- logFile.logTestFileInit("Performance Testing - Reports various
performance metrics using the Transformer");
+ // Generate Unique Run id and processor info
+ const XalanDOMString UniqRunid =
futil.GenerateUniqRunid();
- // Create run entry that contains runid and number of
iterations used for averages.
-
runAttrs.insert(Hashtable::value_type(XalanDOMString("UniqRunid"), UniqRunid));
- logFile.addMetricToAttrs("Iterations",iterCount, runAttrs);
- logFile.logElement(10, "perfdata", runAttrs, "xxx");
+ // Defined basic constants for file manipulation and
open results file
+ const XalanDOMString
resultFilePrefix(XalanDOMString("cpp"));
+ const XalanDOMString resultsFile(outputRoot +
resultFilePrefix + UniqRunid + XMLSuffix);
- // Get the list of sub-directories below "base" and iterate
through them
- const FileNameVectorType dirs =
futil.getDirectoryNames(baseDir);
+ XMLFileReporter logFile(resultsFile);
+ logFile.logTestFileInit("Performance Testing - Reports
various performance metrics using the Transformer");
- for(FileNameVectorType::size_type j = 0; j < dirs.size();
j++)
- {
- // Run specific category of files from given directory
- if (length(category) > 0 && !equals(dirs[j], category))
- {
- continue;
- }
- cout << "Processing files in Directory: " << dirs[j] <<
endl;
+ // Create run entry that contains runid and number of
iterations used for averages.
+
runAttrs.insert(Hashtable::value_type(XalanDOMString("UniqRunid"), UniqRunid));
+ logFile.addMetricToAttrs("Iterations",iterCount,
runAttrs);
+ logFile.logElement(10, "perfdata", runAttrs, "xxx");
- // Check that output directory is there.
- const XalanDOMString theOutputDir = outputRoot +
dirs[j];
- futil.checkAndCreateDir(theOutputDir);
- logFile.logTestCaseInit(XalanDOMString("Performance
Directory: ") + dirs[j] );
- const FileNameVectorType files =
futil.getTestFileNames(baseDir, dirs[j], false);
+ // Get the list of sub-directories below "base" and
iterate through them
+ const FileNameVectorType dirs =
futil.getDirectoryNames(baseDir);
- for(FileNameVectorType::size_type i = 0; i <
files.size(); i++)
+ for(FileNameVectorType::size_type j = 0; j <
dirs.size(); j++)
{
- // Define variables used for timing and
reporting ...
- clock_t startTime, endTime, accmTime, avgEtoe;
- double timeinMilliseconds, theAverage;
- int transformResult;
- Hashtable attrs;
-
-
attrs.insert(Hashtable::value_type(XalanDOMString("idref"), files[i]));
-
attrs.insert(Hashtable::value_type(XalanDOMString("UniqRunid"),UniqRunid));
-
attrs.insert(Hashtable::value_type(XalanDOMString("processor"),processorType));
-
logFile.addMetricToAttrs("Iterations",iterCount, attrs);
-
- if (skip)
+ // Run specific category of files from given
directory
+ if (length(category) > 0 && !equals(dirs[j],
category))
{
- if (checkForExclusion(files[i]))
- continue;
+ continue;
}
- const XalanDOMString theXSLFile= baseDir +
dirs[j] + pathSep + files[i];
- const XalanDOMString theXMLFile =
futil.GenerateFileName(theXSLFile,"xml");
+ cout << "Processing files in Directory: " <<
dirs[j] << endl;
- const XalanDOMString outbase = outputRoot +
dirs[j] + pathSep + files[i];
- const XalanDOMString theOutputFile =
futil.GenerateFileName(outbase, "out");
+ // Check that output directory is there.
+ const XalanDOMString theOutputDir = outputRoot
+ dirs[j];
+ futil.checkAndCreateDir(theOutputDir);
- const XSLTInputSource
xslInputSource(c_wstr(theXSLFile));
- const XSLTInputSource
xmlInputSource(c_wstr(theXMLFile));
- const XSLTResultTarget
theResultTarget(theOutputFile);
-
-
attrs.insert(Hashtable::value_type(XalanDOMString("href"), theXSLFile));
-
- cout << endl << files[i] << endl;
-
- //
- // Time the parsing(compile) of the stylesheet
and report the results..
- //
- startTime = clock();
- const XalanCompiledStylesheet* const
compiledSS = xalan.compileStylesheet(xslInputSource);
- endTime = clock();
- // assert(glbStylesheetRoot != 0);
-
- timeinMilliseconds =
calculateElapsedTime(startTime, endTime);
- cout << " XSL parse: " << timeinMilliseconds
<< " milliseconds." << endl;
-
logFile.addMetricToAttrs("parsexsl",timeinMilliseconds, attrs);
-
- //
- // Time the parsing of the input XML and report
the results..
- //
- startTime = clock();
- XalanParsedSource* parsedSource =
xalan.parseSource(xmlInputSource);
- endTime = clock();
- // assert(glbSourceXML != 0);
-
- timeinMilliseconds =
calculateElapsedTime(startTime, endTime);
- cout << " XML parse: " << timeinMilliseconds
<< " milliseconds." << endl;
-
logFile.addMetricToAttrs("parsexml",timeinMilliseconds, attrs);
-/*
- //
- // Do a total END to END transform with no pre
parsing of either xsl or xml files.
- // And output metrics to console and result log
- //
- startTime = clock();
- transformResult =
xalan.transform(xmlInputSource, xslInputSource, theResultTarget);
- endTime = clock();
- if(!transformResult)
- {
- timeinMilliseconds =
calculateElapsedTime(startTime, endTime);
- cout << " Single eTOe: " <<
timeinMilliseconds << " milliseconds." << endl;
- logFile.addMetricToAttrs("etoe",
timeinMilliseconds, attrs);
- }
- else
- {
- cout << xalan.getLastError();
- return 0;
- }
+
logFile.logTestCaseInit(XalanDOMString("Performance Directory: ") + dirs[j] );
+ const FileNameVectorType files =
futil.getTestFileNames(baseDir, dirs[j], false);
- //
- // Perform a single transform using parsed
stylesheet and unparsed xml source, report results...
- //
- startTime = clock();
- transformResult =
xalan.transform(xmlInputSource, compiledSS, theResultTarget);
- endTime = clock();
- if(!transformResult)
+ for(FileNameVectorType::size_type i = 0; i <
files.size(); i++)
{
+ // Define variables used for timing
and reporting ...
+ clock_t startTime, endTime, accmTime,
avgEtoe;
+ double timeinMilliseconds = 0,
theAverage =0;
+ int transformResult = 0;
+ Hashtable attrs;
+
+
attrs.insert(Hashtable::value_type(XalanDOMString("idref"), files[i]));
+
attrs.insert(Hashtable::value_type(XalanDOMString("UniqRunid"),UniqRunid));
+
attrs.insert(Hashtable::value_type(XalanDOMString("processor"),processorType));
+
logFile.addMetricToAttrs("Iterations",iterCount, attrs);
+
+ if (skip)
+ {
+ if (checkForExclusion(files[i]))
+ continue;
+ }
+
+ const XalanDOMString theXSLFile=
baseDir + dirs[j] + pathSep + files[i];
+ const XalanDOMString theXMLFile =
futil.GenerateFileName(theXSLFile,"xml");
+
+ const XalanDOMString outbase =
outputRoot + dirs[j] + pathSep + files[i];
+ const XalanDOMString theOutputFile =
futil.GenerateFileName(outbase, "out");
+
+ const XSLTInputSource
xslInputSource(c_wstr(theXSLFile));
+ const XSLTInputSource
xmlInputSource(c_wstr(theXMLFile));
+ const XSLTResultTarget
theResultTarget(theOutputFile);
+
+
attrs.insert(Hashtable::value_type(XalanDOMString("href"), theXSLFile));
+
+ cout << endl << files[i] << endl;
+
+ //
+ // Time the parsing(compile) of the XSL
stylesheet and report the results..
+ //
+ startTime = clock();
+ XalanCompiledStylesheet* const
compiledSS = xalan.compileStylesheet(xslInputSource);
+ endTime = clock();
+ // assert(glbStylesheetRoot != 0);
+
timeinMilliseconds =
calculateElapsedTime(startTime, endTime);
- cout << " Single w/parsed XSL: " <<
timeinMilliseconds << " milliseconds." << endl;
- logFile.addMetricToAttrs("single",
timeinMilliseconds, attrs);
- }
- else
- {
- cout << xalan.getLastError();
- return 0;
- }
+ cout << " XSL: " <<
timeinMilliseconds << " milliseconds, Parse" << endl;
+
logFile.addMetricToAttrs("parsexsl",timeinMilliseconds, attrs);
-*/ //
- // Perform multiple transforms and calculate
the average time ..
- // These are done 3 different ways.
- //
- // FIRST: Parsed XSL Stylesheet and Parsed XML
Source.
- //
- accmTime = 0;
- for(int j = 0; j < iterCount; ++j)
- {
+ //
+ // Time the parsing of the input XML
and report the results..
+ //
startTime = clock();
- transformResult =
xalan.transform(*parsedSource, compiledSS, theResultTarget);
+ XalanParsedSource*
parsedSource = xalan.parseSource(xmlInputSource);
endTime = clock();
-
- accmTime += endTime - startTime;
- }
+ // assert(glbSourceXML != 0);
- theAverage = calculateAvgTime(accmTime,
iterCount);
+ timeinMilliseconds =
calculateElapsedTime(startTime, endTime);
+ cout << " XML: " <<
timeinMilliseconds << " milliseconds, Parse" <<endl;
+
logFile.addMetricToAttrs("parsexml",timeinMilliseconds, attrs);
- // Output average transform time to console and
result log
- cout << " Avg: " << theAverage << " for " <<
iterCount << " iter's w/Parsed files" << endl;
-
logFile.addMetricToAttrs("avgparsedxml",theAverage, attrs);
-
- // SECOND: Parsed Stylesheet and UnParsed XML
Source.
- // This is currently how the XalanJ 2.0 is
performing transforms,
- // i.e. with the unparsed XML Source.
-
- accmTime = 0;
- for(int k = 0; k < iterCount; ++k)
- {
-//
- }
+ //
+ // Perform One transform using parsed
stylesheet and unparsed xml source, report results...
+ //
+ startTime = clock();
+ transformResult =
xalan.transform(xmlInputSource, compiledSS, theResultTarget);
+ endTime = clock();
+ if(!transformResult)
+ {
+ timeinMilliseconds =
calculateElapsedTime(startTime, endTime);
+ cout << endl << " One: " <<
timeinMilliseconds << " w/Parsed XSL." << endl;
+
logFile.addMetricToAttrs("single", timeinMilliseconds, attrs);
+ }
+ else
+ {
+ cout << xalan.getLastError();
+ return 0;
+ }
- theAverage = calculateAvgTime(accmTime,
iterCount);
- cout << " Avg: " << theAverage << " for " <<
iterCount << " iter's w/UnParsed XML" << endl;
+ //
+ // Do One eTOe transform with no pre
parsing of either xsl or xml files.
+ // And output metrics to console and
result log
+ //
+ startTime = clock();
+ transformResult =
xalan.transform(xmlInputSource, xslInputSource, theResultTarget);
+ endTime = clock();
+ if(!transformResult)
+ {
+ timeinMilliseconds =
calculateElapsedTime(startTime, endTime);
+ cout << " One: " <<
timeinMilliseconds << " eTOe." << endl;
+
logFile.addMetricToAttrs("etoe", timeinMilliseconds, attrs);
+ }
+ else
+ {
+ cout << xalan.getLastError();
+ return 0;
+ }
-
logFile.addMetricToAttrs("avgunparsedxml",theAverage, attrs);
+ //
+ // Perform multiple transforms and
calculate the average time ..
+ // These are done 3 different ways.
+ //
+ // FIRST: Parsed XSL Stylesheet and
Parsed XML Source.
+ //
+ accmTime = 0;
+ for(int j = 0; j < iterCount; ++j)
+ {
+ startTime = clock();
+ transformResult =
xalan.transform(*parsedSource, compiledSS, theResultTarget);
+ endTime = clock();
+
+ accmTime += endTime - startTime;
+ }
- // THIRD: Neither Stylesheet nor XML Source are
parsed.
- // Perform multiple etoe transforms and
calculate the average ...
-
- avgEtoe = 0;
- for(int jj = 0; jj < iterCount; ++jj)
- {
-//
- }
+ theAverage = calculateAvgTime(accmTime,
iterCount);
+ cout << endl << " Avg: " <<
theAverage << " for " << iterCount << " iter's w/Parsed files" << endl;
+
logFile.addMetricToAttrs("avgparsedxml",theAverage, attrs);
+
+ //
+ // SECOND: Parsed Stylesheet and
UnParsed XML Source.
+ // This is currently how the XalanJ 2.0
is performing transforms,
+ // i.e. with the unparsed XML Source.
+
+ accmTime = 0;
+ for(int k = 0; k < iterCount; ++k)
+ {
+ startTime = clock();
+ transformResult =
xalan.transform(xmlInputSource, compiledSS, theResultTarget);
+ endTime = clock();
+
+ accmTime += endTime -
startTime;
+ }
+ theAverage = calculateAvgTime(accmTime,
iterCount);
+ cout << " Avg: " << theAverage << "
for " << iterCount << " iter's w/UnParsed XML" << endl;
+
logFile.addMetricToAttrs("avgunparsedxml",theAverage, attrs);
+
+ //
+ // THIRD: Neither Stylesheet nor XML
Source are parsed.
+ // Perform multiple etoe transforms and
calculate the average ...
+
+ avgEtoe = 0;
+ for(int jj = 0; jj < iterCount; ++jj)
+ {
+ startTime = clock();
+ transformResult =
xalan.transform(xmlInputSource, xslInputSource, theResultTarget);
+ endTime = clock();
+
+ avgEtoe += endTime - startTime;
+ }
+ theAverage =
calculateAvgTime(avgEtoe,iterCount);
- theAverage =
calculateAvgTime(avgEtoe,iterCount);
+ // Output average transform time to
console and result log
+ cout << " Avg: " << theAverage << "
for " << iterCount << " iter's of eToe" << endl;
+
logFile.addMetricToAttrs("avgetoe",theAverage, attrs);
- // Output average transform time to console and
result log
- cout << " Avg: " << theAverage << " for " <<
iterCount << " iter's of eToe" << endl;
+ logFile.logElement(10, "perf", attrs,
"xxx");
- logFile.addMetricToAttrs("avgetoe",theAverage,
attrs);
+ xalan.destroyParsedSource(parsedSource);
+ xalan.destroyStylesheet(compiledSS);
+ }//for files
- logFile.logElement(10, "perf", attrs, "xxx");
- }//for files
+ logFile.logTestCaseClose(XalanDOMString("Performance
Directory: ") + dirs[j], XalanDOMString("Done") );
+ }//for dirs
- logFile.logTestCaseClose(XalanDOMString("Performance Directory:
") + dirs[j], XalanDOMString("Done") );
- }//for dirs
+ logFile.logTestFileClose("Performance", "Done");
+ logFile.close();
- logFile.logTestFileClose("Performance", "Done");
- logFile.close();
+ } //if getParams
+ }
- } //if getParams
+ XalanTransformer::terminate();
return 0;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]