Anonymous avatar Anonymous committed ffaf594

perfbenchmarker01: put benchmark helper coder into tools module, insert some benchmark test points into desktop, sfx2, sw, vcl, xmloff

Comments (0)

Files changed (17)

desktop/source/app/app.cxx

 #include <svtools/filter.hxx>
 #include <svtools/regoptions.hxx>
 
+#include <tools/benchmark.h>
 #include "langselect.hxx"
 
 #define DEFINE_CONST_UNICODE(CONSTASCII)        UniString(RTL_CONSTASCII_USTRINGPARAM(CONSTASCII))
     // Startup screen
     RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109) Desktop::Main { OpenSplashScreen" );
     OpenSplashScreen();
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Startup_ShowSS);
     RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109) Desktop::Main } OpenSplashScreen" );
 
     {
         aSettings.SetLanguage( eLanguage );
         Application::SetSettings( aSettings );
         RTL_LOGFILE_CONTEXT_TRACE( aLog, "} set locale settings" );
+        TOOLS_PERFORMANCE_DIAGRAM(PDB_Startup_LclSetting );
 
 
         // Check for StarOffice/Suite specific extensions runs also with OpenOffice installation sets
         if ( ! pCmdLineArgs->IsNoFirstStartWizard())
         {
             RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ FirstStartWizard" );
-        
+            TOOLS_PERFORMANCE_DIAGRAM(PDB_Startup_InitEnv);
+
             if (IsFirstStartWizardNeeded())
             {
                 ::svt::RegOptions().removeReminder(); // remove patch registration reminder
         {
             css::document::EventObject aEvent;
             aEvent.EventName = ::rtl::OUString::createFromAscii("OnStartApp");
+            TOOLS_PERFORMANCE_DIAGRAM(PDB_Startup_StartEvent);
             xGlobalBroadcaster->notifyEvent(aEvent);
         }
 
         // the creation of a Java Virtual Machine fails
         com::sun::star::uno::ContextLayer layer2(
             new svt::JavaContext( com::sun::star::uno::getCurrentContext() ) );
-
+            
+	TOOLS_PERFORMANCE_DIAGRAM(PDB_Startup_End);
         Execute();
+        TOOLS_PERFORMANCE_DIAGRAM(PDB_Quit_Start);
     }
     catch(const com::sun::star::document::CorruptedFilterConfigurationException& exFilterCfg)
     {

desktop/source/app/sofficemain.cxx

 #include "precompiled_desktop.hxx"
 
 #include "app.hxx"
-
+#include <tools/benchmark.h>
 #include <rtl/logfile.hxx>
 #include <tools/extendapplicationenvironment.hxx>
 
     tools::extendApplicationEnvironment();
 
 	RTL_LOGFILE_PRODUCT_TRACE( "PERFORMANCE - enter Main()" );
-
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Startup_Start);
 	desktop::Desktop aDesktop;
     // This string is used during initialization of the Gtk+ VCL module
     aDesktop.SetAppName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("soffice")) );

sfx2/source/doc/objstor.cxx

 #include "graphhelp.hxx"
 #include "appbaslib.hxx"
 #include "appdata.hxx"
+#include <tools/benchmark.h>
 
 #ifdef OS2
 #include <osl/file.hxx>
 
 sal_Bool SfxObjectShell::Save_Impl( const SfxItemSet* pSet )
 {
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Save_Start);
 	if ( IsReadOnly() )
 	{
 		SetError( ERRCODE_SFX_DOCUMENTREADONLY, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );

sfx2/source/view/frmload.cxx

 #include <sfx2/docfilt.hxx>
 #include "brokenpackageint.hxx"
 #include "objshimp.hxx"
+#include <tools/benchmark.h>
 
 SfxFrameLoader_Impl::SfxFrameLoader_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory >& /*xFactory*/ )
 {
     static ::rtl::OUString PROP_ASTEMPLATE         = ::rtl::OUString::createFromAscii("AsTemplate"        );
     static ::rtl::OUString PROP_INTERACTIONHANDLER = ::rtl::OUString::createFromAscii("InteractionHandler");
 
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_Start);
 	sal_Bool bLoadState = sal_False;
 
     // this methods assumes that the filter is detected before, usually by calling the detect() method below
     				String aURL = pDoc->GetMedium()->GetName();
     				SFX_APP()->Broadcast( SfxStringHint( SID_OPENURL, aURL ) );
     				bLoadState = sal_True;
+    				TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_BindingFrame);
     			}
                 else
                     bDisaster = sal_True;
 
     xFrame.clear();
     xListener.clear();
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_End);
 	return bLoadState;
 }
 

sw/source/filter/basflt/shellio.cxx

 #include <pausethreadstarting.hxx>
 // <--
 
+#include <tools/benchmark.h>
+
 using namespace ::com::sun::star;
 
 //////////////////////////////////////////////////////////////////////////
 
 	BOOL bWasPurgeOle = pOutDoc->get(IDocumentSettingAccess::PURGE_OLE);
 	pOutDoc->set(IDocumentSettingAccess::PURGE_OLE, false);
-
+	
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Save_XMLStart);
+    
 	ULONG nError = 0;
 	if( pMedium )
 		nError = rxWriter->Write( *pPam, *pMedium, pRealFileName );
     else if( xStg.is() )
         nError = rxWriter->Write( *pPam, xStg, pRealFileName );
 
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Save_XMLEnd);
+    
 	pOutDoc->set(IDocumentSettingAccess::PURGE_OLE, bWasPurgeOle );
 
 	if( pESh )

sw/source/filter/xml/swxml.cxx

 // --> OD 2008-12-17 #i70748#
 #include <sfx2/docfilt.hxx>
 // <--
-
+#include <tools/benchmark.h>
 #include <istyleaccess.hxx>
 #define LOGFILE_AUTHOR "mb93740"
 
 
 	// connect parser and filter
 	xParser->setDocumentHandler( xFilter );
-
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_SetHandler);
 	// connect model and filter
 	uno::Reference < XImporter > xImporter( xFilter, UNO_QUERY );
 	xImporter->setTargetDocument( xModelComponent );
 	try
 	{
 		xParser->parseStream( aParserInput );
+		TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_Parse);
 	}
 	catch( xml::sax::SAXParseException& r )
 	{
     sal_uInt32 nWarn = 0;
 	sal_uInt32 nWarn2 = 0;
 	// read storage streams
+	TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_XMLStart);
 	if( !(IsOrganizerMode() || IsBlockMode() || aOpt.IsFmtsOnly() ||
 		  bInsertMode) )
 	{
 			(bOASIS ? "com.sun.star.comp.Writer.XMLOasisMetaImporter"
 					: "com.sun.star.comp.Writer.XMLMetaImporter"),
 			aEmptyArgs, rName, sal_False );
-
+        TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_Meta);
+        
 		nWarn2 = ReadThroughComponent(
 			xStorage, xModelComp, "settings.xml", NULL, xServiceFactory,
 			(bOASIS ? "com.sun.star.comp.Writer.XMLOasisSettingsImporter"
 					: "com.sun.star.comp.Writer.XMLSettingsImporter"),
 			aFilterArgs, rName, sal_False );
+        TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_Setting);
 	}
 
 	nRet = ReadThroughComponent(
 		(bOASIS ? "com.sun.star.comp.Writer.XMLOasisStylesImporter"
 				: "com.sun.star.comp.Writer.XMLStylesImporter"),
 		aFilterArgs, rName, sal_True );
-
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_Style);
+    
 	if( !nRet && !(IsOrganizerMode() || aOpt.IsFmtsOnly()) )
 		nRet = ReadThroughComponent(
 		   xStorage, xModelComp, "content.xml", "Content.xml", xServiceFactory,
 			(bOASIS ? "com.sun.star.comp.Writer.XMLOasisContentImporter"
 					: "com.sun.star.comp.Writer.XMLContentImporter"),
 		   aFilterArgs, rName, sal_True );
-
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_Content);
+    
 	if( !(IsOrganizerMode() || IsBlockMode() || bInsertMode ||
 		  aOpt.IsFmtsOnly() ) )
 	{
         {
         }
 	}
-
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_XMLEnd);
+    
     // Notify math objects
     if( bInsertMode )
         rDoc.PrtOLENotify( FALSE );

sw/source/ui/app/docsh.cxx

 #include <unomid.h>
 
 #include <sfx2/Metadatable.hxx>
-
+#include <tools/benchmark.h>
 
 using rtl::OUString;
 using namespace ::com::sun::star;
             bLockedView = pWrtShell->IsViewLocked();
             pWrtShell->LockView( TRUE );    //lock visible section
         }
-
+        
+        TOOLS_PERFORMANCE_DIAGRAM(PDB_Save_Prepared);
+        
         SwWriter aWrt( rMedium, *pDoc );
 		nErr = aWrt.Write( xWrt );
 

sw/source/ui/app/docshini.cxx

 #include <globals.hrc>
 #endif
 
-
+#include <tools/benchmark.h>
 // #i18732#
 #include <fmtfollowtextflow.hxx>
 
 					RTL_LOGFILE_CONTEXT_TRACE( aLog, "before ReadDocInfo" );
                     SwReader aRdr( rMedium, aEmptyStr, pDoc );
 					RTL_LOGFILE_CONTEXT_TRACE( aLog, "before Read" );
+					TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_Reader);
 					nErr = aRdr.Read( *pReader );
+					TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_InitData);
 					RTL_LOGFILE_CONTEXT_TRACE( aLog, "after Read" );
 
 					// If a XML document is loaded, the global doc/web doc

tools/inc/tools/benchmark.h

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: benchmark.cxx,v $
+ * $Revision: 0.3 $ 
+ * last change: $Author: liheng $ $Date: 2009/03/02 12:11:03 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+ 
+#ifndef INCLUDED_TOOLS_BENCHMARK_H
+#define INCLUDED_TOOLS_BENCHMARK_H
+
+#include <sal/types.h>
+#include <tools/performance_diagram.h>
+#include "tools/toolsdllapi.h"
+
+#define BENCHMARK_SIMPLE 0
+#define BENCHMARK_CONTEXT 1
+//#define BENCHMARK_USERDEF 2
+#define BENCHMARK_SYSTEMINFO 0xFFFFFFFF
+
+#define BENCHMARK_NODE_STT 0x00000000
+#define BENCHMARK_NODE_END 0xFFFFFFFF
+#define BENCHMARK_NODE_ERR 0xFFFFFFFE
+	
+/* * * * *
+To define macro PERFORMANCE_BENCHMARK for using performance benchmark helper code and diagram tracing.
+Set FLAGs can use export/set ENVCDEFS=-DPERFORMANCE_BENCHMARK -DPERFORMANCE_BENCHMAKR_NOTICK -DPERFORMANCE_BENCHMARK_TIME
+
+* * */
+
+
+TOOLS_DLLPUBLIC	void tools_benchmark_record(
+                                    sal_uInt32 nNodeType, 
+                                    sal_uInt32 nNodeId);
+                                    
+TOOLS_DLLPUBLIC void tools_performance_diagram_info(
+							const char* sNodeName, 
+							const char* sFilename,
+							long nLineNum,
+							sal_uInt32 nNodeId);
+
+#ifdef PERFORMANCE_BENCHMARK
+	#define TOOLS_BENCHMARK_RECORD(TYPE, NODEID) tools_benchmark_record(TYPE, NODEID)
+	#define TOOLS_PERFORMANCE_CONTEXT_DIAGRAM(NODEID) tools_benchmark_record(BENCHMARK_CONTEXT, NODEID)
+	#define TOOLS_PERFORMANCE_DIAGRAM(NODEID) tools_benchmark_record(BENCHMARK_SIMPLE, NODEID)
+#else
+	#define TOOLS_BENCHMARK_RECORD(TYPE, NODEID)  ((void)0)	
+	
+	#ifdef TOOLS_PERFORMANCE_DIAGRAM_INFO //TOOLS_PERFORMANCE_DIAGRAM_INFO 
+		#define TOOLS_PERFORMANCE_CONTEXT_DIAGRAM(NODEID) tools_performance_diagram_info(#NODEID, __FILE__, __LINE__, NODEID)
+		#define TOOLS_PERFORMANCE_DIAGRAM(NODEID) tools_performance_diagram_info(#NODEID, __FILE__, __LINE__, NODEID)
+	#else //TOOLS_PERFORMANCE_DIAGRAM_INFO 
+		#define TOOLS_PERFORMANCE_CONTEXT_DIAGRAM(NODEID) ((void)0)	
+		#define TOOLS_PERFORMANCE_DIAGRAM(NODEID)  ((void)0)	
+	#endif //TOOLS_PERFORMANCE_DIAGRAM_INFO 
+#endif //PERFORMANCE_BENCHMARK
+	
+
+#endif //INCLUDED_TOOLS_BENCHMARK_H

tools/inc/tools/performance_diagram.h

+#ifndef _PERFORMANCE_DIAGRAM_H_
+#define _PERFORMANCE_DIAGRAM_H_
+        //OpenOffice.org Version:3.1.0 Build:300
+		
+        #define PDB_Startup_Start 100
+		#define PDB_Startup_SVMain 120
+		#define PDB_Startup_InitVCL 130
+		#define PDB_Startup_ShowSS 140 //PDB_Startup_ShowSS
+		#define PDB_Startup_InitEnv 150 //FIRST START
+		#define PDB_Startup_LclSetting 160
+		#define PDB_Startup_StartEvent 170
+        #define PDB_Startup_End 101
+
+
+		#define PDB_Load_Start 200
+		#define PDB_Load_Reader 210
+        #define PDB_Load_XMLStart 220
+		#define PDB_Load_Content 221
+		#define PDB_Load_Style 222
+		#define PDB_Load_Setting 223
+		//#define PDB_Load_Content 224
+		#define PDB_Load_Meta 225
+		#define PDB_Load_SetHandler 226
+		#define PDB_Load_Parse 227
+        #define PDB_Load_XMLEnd 230
+		#define PDB_Load_InsertTextCtrlChr 235
+		#define PDB_Load_InitData 240
+		#define PDB_Load_BindingFrame 245
+        #define PDB_Load_CreateView 250
+        #define PDB_Load_End 201
+
+        #define PDB_Save_Start 300
+        #define PDB_Save_XMLStart 310
+        #define PDB_Save_Prepared 320
+		#define PDB_Save_ExporterCreated 330
+        #define PDB_Save_XMLEnd 380
+        #define PDB_Save_FlushView 390
+        #define PDB_Save_End 301
+
+		#define PDB_Quit_Start 900
+#endif //_PERFORMANCE_DIAGRAM_H_

tools/prj/build.lst

 tl	tools\source\inet					nmake	-	all	tl_inet tl_fsys tl_inc NULL
 tl	tools\source\string					nmake	-	all	tl_string tl_fsys tl_inc NULL
 tl  tools\source\misc                   nmake   -   all tl_misc tl_inc NULL
+tl  tools\source\benchmark              nmake   -   all tl_benc tl_inc NULL
 tl	tools\win\source\dll				nmake	-	w	tl_dllw tl_inc NULL
 tl	tools\os2\source\dll				nmake	-	p	tl_dllp tl_inc NULL
 tl	tools\unx\source\dll				nmake	-	u	tl_dllu tl_inc NULL
-tl	tools\util							nmake	-	all	tl_utl tl_com tl_dat tl_deb tl_dllu.u tl_dllp.p tl_dllw.w tl_fsys tl_gen tl_inet tl_mem tl_rc tl_ref tl_str tl_string tl_misc tl_zco tl_ttloader NULL
+tl	tools\util							nmake	-	all	tl_utl tl_com tl_dat tl_deb tl_dllu.u tl_dllp.p tl_dllw.w tl_fsys tl_gen tl_inet tl_mem tl_rc tl_ref tl_str tl_string tl_misc tl_zco tl_ttloader tl_benc NULL
 tl	tools\bootstrp						nmake	-	all	tl_bstrp tl_utl tl_inc NULL
 tl	tools\bootstrp\addexes2				nmake	-	all	tl_bsexes2 tl_bstrp tl_inc NULL
 
 ..\inc\tools\postx.h %_DEST%\inc%_EXT%\tools\postx.h
 ..\inc\tools\prex.h %_DEST%\inc%_EXT%\tools\prex.h
 
+..\inc\tools\benchmark.h %_DEST%\inc%_EXT%\tools\benchmark.h
+..\inc\tools\performance_diagram.h %_DEST%\inc%_EXT%\tools\performance_diagram.h
+
 ..\inc\tools\agapi.hxx %_DEST%\inc%_EXT%\tools\agapi.hxx
 ..\inc\tools\agapi.hxx %_DEST%\inc%_EXT%\tools\agapi.hxx
 ..\inc\tools\agitem.hxx %_DEST%\inc%_EXT%\tools\agitem.hxx

tools/source/benchmark/benchmark.cxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: benchmark.cxx,v $
+ * $Revision: 0.3 $ 
+ * last change: $Author: liheng $ $Date: 2009/03/02 12:11:03 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <osl/process.h>
+#include <osl/time.h>
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+#include <osl/file.h>
+#include <osl/getglobalmutex.hxx>
+
+#include <rtl/instance.hxx>
+#include <rtl/bootstrap.h>
+#include <rtl/string.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <tools/benchmark.h>
+
+
+using namespace rtl;
+using namespace osl;
+
+namespace {
+    
+typedef struct
+{
+	sal_uInt32 recordType;
+	sal_uInt32 nodeId;
+	sal_uInt32 threadInfo;
+	sal_uInt32 contextInfo;
+	sal_uInt64 tick;    //for java benchmark Date.getTime was long bit
+	sal_uInt64 time;
+} BenchmarkRecord;
+
+//mutex
+struct Init
+{
+  Mutex * operator()()
+  {
+      static Mutex aInstance;
+      return &aInstance;
+  }
+};
+
+Mutex & getLocalMutex()
+{
+  return *rtl_Instance< Mutex, Init, ::osl::MutexGuard,
+                       ::osl::GetGlobalMutex >::create(
+                            Init(), ::osl::GetGlobalMutex());
+}
+
+/*
+inline Mutex & getLocalMutex()
+{
+	static Mutex *pMutex = 0;
+	if( !pMutex )
+	{
+		MutexGuard guard( Mutex::getGlobalMutex() );
+		if( ! pMutex )
+		{
+			static Mutex mutex;
+			pMutex = &mutex;
+		}
+	}
+	return *pMutex;
+}
+*/
+
+OUString getFileUrl( const OUString &name )
+{
+	OUString aRet;
+	if ( osl_getFileURLFromSystemPath( name.pData, &aRet.pData )
+         != osl_File_E_None )
+    {
+        OSL_ASSERT( false );
+    }
+
+	OUString aWorkingDirectory;
+	osl_getProcessWorkingDir( &(aWorkingDirectory.pData) );
+	osl_getAbsoluteFileURL( aWorkingDirectory.pData, aRet.pData, &(aRet.pData) );
+
+	return aRet;
+}
+
+OUString& getBenchmarkFileName()
+{
+	static OUString sPath;
+	static sal_Bool bGotIt = sal_False;
+	if(!bGotIt)
+	{
+		OUString name( RTL_CONSTASCII_USTRINGPARAM( "PERFORMANCE_DIAGRAM" ));
+		OUString value;
+		OUStringBuffer path;
+		path.appendAscii( "perfdgm_");
+		oslProcessIdentifier aProcessId = 0;
+		oslProcessInfo info;
+		info.Size = sizeof (oslProcessInfo);
+		if (osl_getProcessInfo (0, osl_Process_IDENTIFIER, &info) == osl_Process_E_None)
+		{
+			aProcessId = info.Ident;
+		}
+		if( rtl_bootstrap_get( name.pData, &value.pData, 0 ) )
+		{
+			path.append(value);
+			path.appendAscii( "_" );
+		}
+        else
+        {
+			path.append( (sal_Int32) aProcessId );
+		}
+		path.appendAscii( ".log" );
+		sPath = getFileUrl( path.makeStringAndClear() );
+		bGotIt = sal_True;
+	}
+	return sPath;
+}
+
+#ifdef UNX
+inline volatile long long RDTSC()
+{
+	register long long TSC asm("eax");
+	asm volatile (".byte 0x0f,0x31" : : : "eax","edx");
+	return TSC;
+}
+#endif
+
+template<sal_uInt32 BOUNDARY>
+class CaseRecord
+{
+private:
+	BenchmarkRecord     mBuffer[BOUNDARY];
+	sal_uInt32          mIndex;
+	OUString            mFileName;
+	oslFileHandle       mFile;
+	Mutex&              mMutex;
+	
+public:
+	CaseRecord() : 
+	    mIndex(0), 
+	    mFile(NULL), 
+	    mMutex(getLocalMutex())
+	{
+		sal_uInt32 context = 0x0;
+#ifdef PERFORMANCE_BENCHMARK_NOTICK
+		context |= 0x00000001;
+#endif //PERFORMANCE_BENCHMARK_NOTICK
+
+#ifdef PERFORMANCE_BENCHMARK_TIME
+		context |= 0x00000002;
+#endif //PERFORMANCE_BENCHMARK_TIME
+
+#ifdef PERFORMANCE_BENCHMARK_THREAD
+		context |= 0x00000004;
+#endif //PERFORMANCE_BENCHMARK_THREAD
+
+#ifdef UNX
+		context |= 0x10000;
+#endif //UNX		
+
+		insertWithContext(BENCHMARK_SYSTEMINFO, 
+                    		BENCHMARK_NODE_STT, 
+                    		context);
+	}
+
+	~CaseRecord()
+	{
+		insertWithContext(BENCHMARK_SYSTEMINFO, 
+                    		BENCHMARK_NODE_END, 
+                    		sizeof(BenchmarkRecord));
+		dump();
+		osl_closeFile(mFile);
+	}
+
+private:
+	void openLogFile()
+	{
+		if(mFile == NULL){
+			mFileName = getBenchmarkFileName();
+			MutexGuard guard(mMutex);
+			OUString sLogName = getBenchmarkFileName();
+			oslFileError e = osl_openFile(sLogName.pData, &mFile, 
+			    osl_File_OpenFlag_Write|osl_File_OpenFlag_Create);
+			if( osl_File_E_EXIST == e)
+			{
+				e=osl_openFile(sLogName.pData, &mFile, osl_File_OpenFlag_Write);
+			}
+			if( osl_File_E_None != e )
+			{
+				mFile = NULL;
+			}
+		}
+	}
+	
+	void dump(){//synchronous
+		MutexGuard guard(mMutex);
+		openLogFile();
+		if(mFile!=NULL)
+		{
+			sal_uInt64 nWritten;
+			osl_writeFile( mFile, mBuffer, 
+			    (sal_Int64)sizeof(BenchmarkRecord)*(mIndex), &nWritten);
+			mIndex=0; //reflush buffer
+		}
+	}
+
+	inline BenchmarkRecord& makeRecord(BenchmarkRecord& record, 
+                                    	sal_uInt32 nType, 
+                                    	sal_uInt32 nNodeId)
+	{
+		record.recordType = nType;
+		record.nodeId= nNodeId;
+		record.threadInfo = 0;
+		sal_uInt64 tick = 0L;
+
+		#ifdef PERFORMANCE_BENCHMARK_NOTICK
+			record.time = osl_getGlobalTimer();
+		#else
+			#ifdef WNT
+				_asm
+				{
+					RDTSC
+					mov DWORD PTR tick, eax
+					mov DWORD PTR tick+4, edx
+				}
+			#else //WNT
+				#ifdef UNX
+					//GCC INLINE-code
+					tick = RDTSC();
+					//record.time =osl_getGlobalTimer();
+				#else //UNX
+					//Can't Support CPU tick 
+					record.time = osl_getGlobalTimer();
+				#endif //UNX
+			#endif //WNT
+				record.tick = tick;
+			#ifdef PERFORMANCE_BENCHMARK_TIME
+				record.time = osl_getGlobalTimer();
+			#endif
+		#endif
+
+		return record;
+	}
+
+	inline void trytoDump(sal_uInt32, sal_uInt32 nNodeId)
+	{
+		if(nNodeId == 0)
+		{
+			dump();
+		}
+		else if(mIndex == BOUNDARY)
+		{
+			dump();
+		}
+		else if(mIndex > BOUNDARY)
+		{
+			//exception!
+			mIndex = BOUNDARY;
+			dump();
+			insert(BENCHMARK_SYSTEMINFO, BENCHMARK_NODE_ERR); //Error case
+			dump();
+		}
+	}
+	
+public:
+    
+	void insertWithContext(sal_uInt32 nType,
+							sal_uInt32 nNodeId,
+							sal_uInt32 nContextInfo) //Thread support
+	{
+		MutexGuard guard(mMutex);
+		BenchmarkRecord& record = makeRecord(mBuffer[mIndex], nType, nNodeId);
+		oslThreadIdentifier threadId = osl_getThreadIdentifier(0);
+		record.threadInfo = threadId;
+		record.time = osl_getGlobalTimer();
+		record.contextInfo = nContextInfo;
+		++mIndex;
+		trytoDump(nType, nNodeId);
+	}
+
+	void insert(sal_uInt32 nType,sal_uInt32 nNodeId)
+	{
+		MutexGuard guard(mMutex);
+		//BenchmarkRecord record;// = Buffer[Index];
+		makeRecord(mBuffer[mIndex], nType, nNodeId);
+		++mIndex;
+		trytoDump(nType,nNodeId);
+	}
+};
+
+} //namespace
+
+void tools_benchmark_record(
+					sal_uInt32 nType, 
+					sal_uInt32 nNodeId)
+{
+	static CaseRecord<50> gCaseRecord;
+	if(nType == BENCHMARK_CONTEXT)
+	{
+		gCaseRecord.insertWithContext(nType, nNodeId, 0);
+	}
+	else
+	{
+		gCaseRecord.insert(nType, nNodeId);
+	}
+}
+
+
+/* *
+To print diagram node information, after this
+run atom case for printing all information. DiagramBuilder
+can build the xxx_diagram.xml with this log
+*/
+void tools_performance_diagram_info(
+							const char* sNodeName, 
+							const char* sFilename,
+							long nLineNum,
+							sal_uInt32 nNodeId)
+{
+	Mutex& mutex = getLocalMutex();
+	MutexGuard guard(mutex);
+	OUStringBuffer path;
+	path.appendAscii( "perfdgm_info.log");
+	OUString sLogName = getFileUrl( path.makeStringAndClear() );
+	oslFileHandle aFile = NULL;
+	oslFileError e = osl_openFile(sLogName.pData, &aFile, 
+	                        osl_File_OpenFlag_Write|osl_File_OpenFlag_Create);
+	if( osl_File_E_EXIST == e)
+	{
+		e = osl_openFile(sLogName.pData, &aFile, osl_File_OpenFlag_Write);
+	}
+	if( osl_File_E_None == e )
+	{
+		e = osl_setFilePos( aFile, osl_Pos_End, (sal_Int64)0);
+		OUStringBuffer buf(16);
+		buf.appendAscii(sNodeName);
+		buf.appendAscii(",");
+		buf.append((sal_Int32)nNodeId);
+		buf.appendAscii(",");
+		buf.appendAscii(sFilename);
+		buf.appendAscii(",");
+		buf.append((sal_Int32)nLineNum);
+		buf.appendAscii(",");
+        oslThreadIdentifier threadId = osl_getThreadIdentifier(0);
+		buf.append((sal_Int32)threadId);
+		buf.appendAscii("\n");
+        sal_uInt64 nWritten;
+		e=osl_writeFile( aFile, buf.getStr(), sizeof(sal_Unicode)*buf.getLength(), &nWritten);
+		e=osl_closeFile(aFile);
+	}//else dump error
+}
+

tools/source/benchmark/makefile.mk

+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.6 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org.  If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=tools
+TARGET=benchmark
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE :  settings.mk
+.INCLUDE :      $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(SYSTEM_ZLIB)" == "YES"
+CFLAGS+=-DSYSTEM_ZLIB
+.ENDIF
+SLOFILES=	$(SLO)$/benchmark.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE :  target.mk

tools/util/makefile.mk

             $(SLB)$/zcodec.lib      \
             $(SLB)$/inet.lib        \
             $(SLB)$/testtoolloader.lib \
-            $(SLB)$/misc.lib
+            $(SLB)$/misc.lib			\
+            $(SLB)$/benchmark.lib
 
 .IF "$(OS)"=="MACOSX"
 SHL1STDLIBS += $(CPPULIB)	 \

vcl/source/app/svmain.cxx

 #include "rtl/strbuf.hxx"
 #endif
 
+#include <tools/benchmark.h>
+
 using namespace ::rtl;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::lang;
 {
     // The 'real' SVMain()
     RTL_LOGFILE_CONTEXT( aLog, "vcl (ss112471) ::SVMain" );
-
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Startup_SVMain);
+    
     ImplSVData* pSVData = ImplGetSVData();
 
     DBG_ASSERT( pSVData->mpApp, "no instance of class Application" );
 
     Reference<XMultiServiceFactory> xMS;
 
-
     BOOL bInit = InitVCL( xMS );
-
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Startup_InitVCL);
+    
     if( bInit )
     {
         // Application-Main rufen

xmloff/source/text/txtimp.cxx

 // --> OD 2008-04-25 #refactorlists#
 #include <txtlists.hxx>
 // <--
+#include <tools/benchmark.h>
 
 using ::rtl::OUString;
 using ::rtl::OUStringBuffer;
 	DBG_ASSERT( xCursorAsRange.is(), "no range" );
 	if( xText.is() )
 		xText->insertControlCharacter( xCursorAsRange, nControl, sal_False );
+    TOOLS_PERFORMANCE_DIAGRAM(PDB_Load_InsertTextCtrlChr);
 }
 
 void XMLTextImportHelper::InsertTextContent(
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.