pauldick    00/11/03 13:07:28

  Added:       c/Tests/Performance perf.dsw perf.dsp perf.cpp
  Log:
  Initial Checkin
  
  Revision  Changes    Path
  1.1                  xml-xalan/c/Tests/Performance/perf.dsw
  
  Index: perf.dsw
  ===================================================================
  Microsoft Developer Studio Workspace File, Format Version 6.00
  # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
  
  
###############################################################################
  
  Project: "perf"=".\perf.dsp" - Package Owner=<4>
  
  Package=<5>
  {{{
  }}}
  
  Package=<4>
  {{{
  }}}
  
  
###############################################################################
  
  Global:
  
  Package=<5>
  {{{
  }}}
  
  Package=<3>
  {{{
  }}}
  
  
###############################################################################
  
  
  
  
  1.1                  xml-xalan/c/Tests/Performance/perf.dsp
  
  Index: perf.dsp
  ===================================================================
  # Microsoft Developer Studio Project File - Name="perf" - Package Owner=<4>
  # Microsoft Developer Studio Generated Build File, Format Version 6.00
  # ** DO NOT EDIT **
  
  # TARGTYPE "Win32 (x86) Console Application" 0x0103
  
  CFG=perf - Win32 Debug
  !MESSAGE This is not a valid makefile. To build this project using NMAKE,
  !MESSAGE use the Export Makefile command and run
  !MESSAGE 
  !MESSAGE NMAKE /f "perf.mak".
  !MESSAGE 
  !MESSAGE You can specify a configuration when running NMAKE
  !MESSAGE by defining the macro CFG on the command line. For example:
  !MESSAGE 
  !MESSAGE NMAKE /f "perf.mak" CFG="perf - Win32 Debug"
  !MESSAGE 
  !MESSAGE Possible choices for configuration are:
  !MESSAGE 
  !MESSAGE "perf - Win32 Release" (based on "Win32 (x86) Console Application")
  !MESSAGE "perf - Win32 Debug" (based on "Win32 (x86) Console Application")
  !MESSAGE 
  
  # Begin Project
  # PROP AllowPerConfigDependencies 0
  # PROP Scc_ProjName ""
  # PROP Scc_LocalPath ""
  CPP=cl.exe
  RSC=rc.exe
  
  !IF  "$(CFG)" == "perf - Win32 Release"
  
  # PROP BASE Use_MFC 0
  # PROP BASE Use_Debug_Libraries 0
  # PROP BASE Output_Dir "Release"
  # PROP BASE Intermediate_Dir "Release"
  # PROP BASE Target_Dir ""
  # PROP Use_MFC 0
  # PROP Use_Debug_Libraries 0
  # PROP Output_Dir "..\..\Build\Win32\VC6\Release"
  # PROP Intermediate_Dir "..\..\Build\Win32\VC6\Release\Performance"
  # PROP Ignore_Export_Lib 0
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D 
"_MBCS" /YX /FD /c
  # ADD CPP /nologo /W4 /GX /O2 /I "..\..\..\..\xml-xerces\c\src" /I 
"..\..\src\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
  # ADD BASE RSC /l 0x409 /d "NDEBUG"
  # ADD RSC /l 0x409 /d "NDEBUG"
  BSC32=bscmake.exe
  # ADD BASE BSC32 /nologo
  # ADD BSC32 /nologo
  LINK32=link.exe
  # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib 
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib 
odbccp32.lib /nologo /subsystem:console /machine:I386
  # ADD LINK32 ..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib 
..\..\Build\Win32\VC6\Release\*.lib  kernel32.lib user32.lib gdi32.lib 
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib 
uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
  
  !ELSEIF  "$(CFG)" == "perf - Win32 Debug"
  
  # PROP BASE Use_MFC 0
  # PROP BASE Use_Debug_Libraries 1
  # PROP BASE Output_Dir "Debug"
  # PROP BASE Intermediate_Dir "Debug"
  # PROP BASE Target_Dir ""
  # PROP Use_MFC 0
  # PROP Use_Debug_Libraries 1
  # PROP Output_Dir "..\..\Build\Win32\VC6\Debug"
  # PROP Intermediate_Dir "..\..\Build\Win32\VC6\Debug\Performance"
  # PROP Ignore_Export_Lib 0
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D 
"_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
  # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D 
"_MBCS" /YX /FD /GZ /c
  # ADD BASE RSC /l 0x409 /d "_DEBUG"
  # ADD RSC /l 0x409 /d "_DEBUG"
  BSC32=bscmake.exe
  # ADD BASE BSC32 /nologo
  # ADD BSC32 /nologo
  LINK32=link.exe
  # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib 
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib 
odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
  # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib 
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib 
odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
  
  !ENDIF 
  
  # Begin Target
  
  # Name "perf - Win32 Release"
  # Name "perf - Win32 Debug"
  # Begin Source File
  
  SOURCE=.\perf.cpp
  # End Source File
  # End Target
  # End Project
  
  
  
  1.1                  xml-xalan/c/Tests/Performance/perf.cpp
  
  Index: perf.cpp
  ===================================================================
  #include <cassert>
  #include <fstream>
  #include <iostream>
  #include <strstream>
  
  #if !defined(NDEBUG) && defined(_MSC_VER)
  #include <crtdbg.h>
  #endif
  
  //These came from the debug test.
  #include <cstdio>
  #include <ctime>
  #include <string>
  #include <vector>
  
  #include <util/PlatformUtils.hpp>
  
  #include <PlatformSupport/DOMStringHelper.hpp>
  #include <PlatformSupport/XalanFileOutputStream.hpp>
  #include <PlatformSupport/XalanOutputStreamPrintWriter.hpp>
  #include <XercesParserLiaison/XercesDOMSupport.hpp>
  
  #include <XPath/XObjectFactoryDefault.hpp>
  #include <XPath/XPathSupportDefault.hpp>
  #include <XPath/XPathFactoryDefault.hpp>
  
  #include <XSLT/StylesheetConstructionContextDefault.hpp>
  #include <XSLT/StylesheetExecutionContextDefault.hpp>
  #include <XSLT/StylesheetRoot.hpp>
  #include <XSLT/XSLTEngineImpl.hpp>
  #include <XSLT/XSLTInit.hpp>
  #include <XSLT/XSLTInputSource.hpp>
  #include <XSLT/XSLTProcessorEnvSupportDefault.hpp>
  #include <XSLT/XSLTResultTarget.hpp>
  
  #include <XercesParserLiaison/XercesParserLiaison.hpp>
  
  
  //This is here for the threads.
  #define WIN32_LEAN_AND_MEAN
  #include <windows.h>
  #include <winbase.h>
  #define THREADFUNCTIONRETURN DWORD WINAPI
  
  #if !defined(XALAN_NO_NAMESPACES)
        using std::cerr;
        using std::cout;
        using std::cin;
        using std::endl;
        using std::ifstream;
        using std::ios_base;
        using std::ostrstream;
        using std::string;
  #endif
  
  
  // This is here for memory leak testing.
  #if defined(_DEBUG)
  #include <crtdbg.h>
  #endif
  
  
  const char* const     xslStylesheets[] =
  {
        "v:\\xsl-test\\prod\\misc\\misc-chess",
        "v:\\xsl-test\\perf\\basic\\basic-all_well",
        "v:\\xsl-test\\perf\\basic\\basic-datetranscode",
        "v:\\xsl-test\\perf\\basic\\basic-dict2",
        "v:\\xsl-test\\perf\\basic\\basic-Fischer-Euwe",
        "v:\\xsl-test\\perf\\basic\\basic-queens", 
        "v:\\xsl-test\\perf\\large\\large-all_well",
        //"v:\\xsl-test\\perf\\large\\large-evans_large", 
        "v:\\xsl-test\\perf\\nodes\\nodes-fancy_xml_tree_viewer_34",
        "v:\\xsl-test\\perf\\nodes\\nodes-showtree-19991008",
        "v:\\xsl-test\\perf\\sort\\sort-big",
        "v:\\xsl-test\\perf\\xpath\\xpath-evans_small",
        "v:\\xsl-test\\perf\\xpath\\xpath-evans_tiny",
        0
  };
  
  
  
  // Used to hold compiled stylesheet, and source document.
  StylesheetRoot*               glbStylesheetRoot[sizeof(xslStylesheets) / 
sizeof(const char*)];
  
  XalanNode*                    glbSourceDoc[sizeof(xslStylesheets) / 
sizeof(const char*)];
  
  
  
  void
  outputMessage(int iter)
  {
                cout << "\n" << "Starting Iteration: " << iter << '\0';
  }
  
  
  
  int
  main(
                        int                             argc,
                        const char*             argv [])
  {
        assert(sizeof(glbStylesheetRoot) == sizeof(glbSourceDoc));
  
  #if !defined(NDEBUG) && defined(_MSC_VER)
        _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | 
_CRTDBG_LEAK_CHECK_DF);
  
        _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
        _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
  #endif
  
        if (argc > 2)
        {
                cerr << "Usage: perf"
                         << endl
                         << endl;
        }
        else
        {
                int     iterCount = 1;
  
                if (argc == 2)
                {
                        iterCount = atoi(argv[1]);
                }
  
  
                try
                {
                        // Call the static initializers...
                        XMLPlatformUtils::Initialize();
  
                        {
                                XSLTInit        theInit;
  
                                // Create the necessary stuff to compile the 
stylesheet.
                                XercesDOMSupport                            
csDOMSupport;
                                XercesParserLiaison                             
csParserLiaison(csDOMSupport);
                                XPathSupportDefault                             
csXPathSupport(csDOMSupport);
                                XSLTProcessorEnvSupportDefault  
csXSLTProcessorEnvSupport;
                                XObjectFactoryDefault                   
csXObjectFactory;
                                XPathFactoryDefault                             
csXPathFactory;
  
                                // Create a processor to compile the 
stylesheet...
                                XSLTEngineImpl  csProcessor(
                                                csParserLiaison,
                                                csXPathSupport,
                                                csXSLTProcessorEnvSupport,
                                                csDOMSupport,
                                                csXObjectFactory,
                                                csXPathFactory);
  
                                // Connect the processor to the support 
object...
                                
csXSLTProcessorEnvSupport.setProcessor(&csProcessor);
  
                                // Create separate factory support objects so 
the stylesheet's
                                // factory-created XObject and XPath instances 
are independent 
                                // from processor's.
                                XObjectFactoryDefault   
csStylesheetXObjectFactory;
                                XPathFactoryDefault             
csStylesheetXPathFactory;
  
                                // Create a stylesheet construction context, 
using the
                                // stylesheet's factory support objects.
                                StylesheetConstructionContextDefault    
csConstructionContext(
                                                                                
                                csProcessor,
                                                                                
                                csXSLTProcessorEnvSupport,
                                                                                
                                csStylesheetXPathFactory);
  
                                const XalanDOMString  theXSLSuffix(".xsl");
                                const XalanDOMString  theXMLSuffix(".xml");
                                const XalanDOMString  theoutputSuffix(".out");
  
                                for(int i = 0; xslStylesheets[i] != 0; i++)
                                {
                                        const XalanDOMString  
theXSLFilename(XalanDOMString(xslStylesheets[i]) + theXSLSuffix);
                                        const XalanDOMString  
theXMLFilename(XalanDOMString(xslStylesheets[i]) + theXMLSuffix);
  
                                        cout << "Now compiling Stylesheet: " << 
xslStylesheets[i] << endl;
  
                                        //Generate the XML and XSL input 
objects.
                                        XSLTInputSource         
csStylesheetSourceXSL(c_wstr(theXSLFilename));
                                        XSLTInputSource         
csDocumentSource(c_wstr(theXMLFilename));
  
                                        // Ask the processor to create a 
StylesheetRoot for the specified
                                        // input XSL.  This is the compiled 
stylesheet.  We don't have to
                                        // delete it, since it is owned by the 
StylesheetConstructionContext
                                        // instance.
                                        glbStylesheetRoot[i] = 
csProcessor.processStylesheet(csStylesheetSourceXSL,
                                                                                
                                   csConstructionContext);
                                        assert(glbStylesheetRoot[i] != 0);
  
                                        // Have the processor create a compiled 
SourceDocument for the specified
                                        // input XML. 
                                        glbSourceDoc[i] = 
csProcessor.getSourceTreeFromInput(csDocumentSource);
                                        assert(glbSourceDoc[i] != 0);
                                }
  
  
                                        for(int ii = 0; xslStylesheets[ii] != 
0; ii++)
                                        {
                                                cout << endl << "Now running 
test: " << xslStylesheets[ii] << endl;
  
                                                // Create the necessary stuff 
to run the processor.
                                                XercesDOMSupport                
                psDOMSupport;
                                                XercesParserLiaison             
                psParserLiaison(psDOMSupport);
                                                XPathSupportDefault             
                psXPathSupport(psDOMSupport);
                                                XSLTProcessorEnvSupportDefault  
psXSLTProcessorEnvSupport;
                                                XObjectFactoryDefault           
        psXObjectFactory;
                                                XPathFactoryDefault             
                psXPathFactory;
  
                                                // Create a processor to 
perform the transform.
                                                XSLTEngineImpl  psProcessor(
                                                        psParserLiaison,
                                                        psXPathSupport,
                                                        
psXSLTProcessorEnvSupport,
                                                        psDOMSupport,
                                                        psXObjectFactory,
                                                        psXPathFactory);
  
                                                // Connect the processor to the 
support object...
                                                
psXSLTProcessorEnvSupport.setProcessor(&psProcessor);
  
                                                // The execution context uses 
the same factory support objects as
                                                // the processor, since those 
objects have the same lifetime as
                                                // other objects created as a 
result of the execution.
                                                
StylesheetExecutionContextDefault               psExecutionContext(
                                                                psProcessor,
                                                                
psXSLTProcessorEnvSupport,
                                                                psXPathSupport,
                                                                
psXObjectFactory);
  
                                                const XalanDOMString  
outputFileName(XalanDOMString(xslStylesheets[ii]) + theoutputSuffix);
  
                                                //Generate the XML input and 
output objects.
                                                XSLTInputSource         
csDocumentSource(glbSourceDoc[ii]);
                                                XSLTResultTarget        
theResultTarget(outputFileName);
  
                                                // Set the stylesheet to be the 
compiled stylesheet. Then do the transform.
                                                const double startTime = 
clock();
                                                cout << "Clock before 
transforms: " << startTime << endl;
                                                for(int j = 0; j < iterCount; 
++j)
                                                {       
                                                        
psProcessor.setStylesheetRoot(glbStylesheetRoot[ii]);
                                                        
psProcessor.process(csDocumentSource, theResultTarget,psExecutionContext);
                                                        
psExecutionContext.reset();
                                                }
                                                const double endTime = clock();
                                                cout << "Clock after 
transforms: " << endTime << endl;
                                                cout << "Total clock ticks: " 
<< endTime - startTime << endl;
                                                const double    millis = 
((endTime - startTime) / CLOCKS_PER_SEC) * 1000.0;
                                                cout << "Milliseconds: " << 
millis << endl;
                                                cout << "Averaged: " << millis 
/ iterCount << " per iteration" << endl;
                                        }
                                
                        }
  
                        XMLPlatformUtils::Terminate();
                }
                catch(...)
                {
                        cerr << "Exception caught!!!"
                                 << endl
                                 << endl;
                }
        }
  
        return 0;
  }
  
  
  

Reply via email to