diff options
author | Thomas Arnhold <thomas@arnhold.org> | 2011-02-15 01:18:16 +0100 |
---|---|---|
committer | Thomas Arnhold <thomas@arnhold.org> | 2011-02-15 13:27:12 +0100 |
commit | 6d3f9a4848fc141eb1a87bc77e16ae851d62fe8e (patch) | |
tree | d47ddb881f6245838dfe2121f648ae11bf2c25ad /xmlhelp | |
parent | 708c0caa14a2cfe375c146755640c1a0a518c941 (diff) |
Remove TEST_DBHELP
Diffstat (limited to 'xmlhelp')
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/databases.cxx | 20 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/db.cxx | 202 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/db.hxx | 6 |
3 files changed, 0 insertions, 228 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx index 2ca87546fed6..5c6b6fafcf08 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.cxx +++ b/xmlhelp/source/cxxhelp/provider/databases.cxx @@ -664,15 +664,6 @@ Db* Databases::getBerkeley( const rtl::OUString& Database, { DBHelp* pDBHelp = new DBHelp( fileNameDBHelp, m_xSFA ); table->setDBHelp( pDBHelp ); - -#ifdef TEST_DBHELP - bool bSuccess; - bool bOldDbAccess = false; - bSuccess = pDBHelp->testAgainstDb( fileName, bOldDbAccess ); - - bOldDbAccess = true; - bSuccess = pDBHelp->testAgainstDb( fileName, bOldDbAccess ); -#endif } else if( table->open( 0,fileName.getStr(),0,DB_BTREE,DB_RDONLY,0644 ) ) { @@ -1007,17 +998,6 @@ KeywordInfo* Databases::getKeyword( const rtl::OUString& Database, if( pDBHelp != NULL ) pDBHelp->releaseHashMap(); } - -#ifdef TEST_DBHELP - bool bSuccess; - bool bOldDbAccess = false; - bSuccess = aDBHelp.testAgainstDb( fileName, bOldDbAccess ); - - bOldDbAccess = true; - bSuccess = aDBHelp.testAgainstDb( fileName, bOldDbAccess ); - - int nDummy = 0; -#endif } else if( 0 == table.open( 0,fileName.getStr(),0,DB_BTREE,DB_RDONLY,0644 ) ) diff --git a/xmlhelp/source/cxxhelp/provider/db.cxx b/xmlhelp/source/cxxhelp/provider/db.cxx index ee5588151004..5b83ae88d435 100644 --- a/xmlhelp/source/cxxhelp/provider/db.cxx +++ b/xmlhelp/source/cxxhelp/provider/db.cxx @@ -36,10 +36,6 @@ #include "com/sun/star/io/XSeekable.hpp" -#ifdef TEST_DBHELP -#include <osl/time.h> -#endif - using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::io; @@ -92,204 +88,6 @@ bool DBHelp::implReadLenAndData( const char* pData, int& riPos, DBData& rValue ) return bSuccess; } -#ifdef TEST_DBHELP - -typedef std::pair< rtl::OString, rtl::OString > KeyValPair; -typedef std::vector< KeyValPair > KeyValPairVector; - -void testWriteKeyValue( FILE* pFile, const KeyValPair& rKeyValPair ) -{ - if( pFile == NULL ) - return; - char cLF = 10; - - const rtl::OString& aKeyStr = rKeyValPair.first; - const rtl::OString& aValueStr = rKeyValPair.second; - int nKeyLen = aKeyStr.getLength(); - int nValueLen = aValueStr.getLength(); - fprintf( pFile, "%x ", nKeyLen ); - if( nKeyLen > 0 ) - fwrite( aKeyStr.getStr(), 1, nKeyLen, pFile ); - fprintf( pFile, " %x ", nValueLen ); - if( nValueLen > 0 ) - fwrite( aValueStr.getStr(), 1, nValueLen, pFile ); - fprintf( pFile, "%c", cLF ); -} - -bool DBHelp::testAgainstDb( const rtl::OString& fileName, bool bOldDbAccess ) -{ - bool bSuccess = true; - - KeyValPairVector avKeyValPair; - - rtl::OString aOutFileName = fileName; - aOutFileName += "_TestOut"; - if( bOldDbAccess ) - aOutFileName += "_Old"; - FILE* pFile = fopen( aOutFileName.getStr(), "wb" ); - - // Get all values - Db table; - if( 0 == table.open( 0,fileName.getStr(),0,DB_BTREE,DB_RDONLY,0644 ) ) - { - bool first = true; - - Dbc* cursor = 0; - table.cursor( 0,&cursor,0 ); - Dbt key_,data; - key_.set_flags( DB_DBT_MALLOC ); // Initially the cursor must allocate the necessary memory - data.set_flags( DB_DBT_MALLOC ); - - while( cursor && DB_NOTFOUND != cursor->get( &key_,&data,DB_NEXT ) ) - { - rtl::OString keyword( static_cast<sal_Char*>(key_.get_data()), - key_.get_size() ); - rtl::OString value( static_cast<sal_Char*>(data.get_data()), - data.get_size() ); - - KeyValPair aPair( keyword, value ); - avKeyValPair.push_back( aPair ); - if( pFile != NULL ) - testWriteKeyValue( pFile, aPair ); - - if( first ) - { - key_.set_flags( DB_DBT_REALLOC ); - data.set_flags( DB_DBT_REALLOC ); - first = false; - } - } - - if( cursor ) cursor->close(); - } - table.close( 0 ); - - // TEST - DBData aDBData; - Db tableTest; - Dbt data; - - int nOkCount = 0; - int nErrCount = 0; - - bool bTestSuccess; - const char* pTestReadData = NULL; - int nTestReadDataSize = 0; - - sal_uInt32 starttime = osl_getGlobalTimer(); - sal_uInt32 afterfirsttime = starttime; - - if( pFile != NULL ) - { - if( bOldDbAccess ) - fprintf( pFile, "\nTesting old access:\n" ); - else - fprintf( pFile, "\nTesting new access:\n" ); - } - - KeyValPairVector::const_iterator it; - bool bFirst = true; - for( it = avKeyValPair.begin() ; it != avKeyValPair.end() ; ++it ) - { - const KeyValPair& rKeyValPair = *it; - - const rtl::OString& aKeyStr = rKeyValPair.first; - const rtl::OString& aValueStr = rKeyValPair.second; - int nKeyLen = aKeyStr.getLength(); - int nValueLen = aValueStr.getLength(); - - const sal_Char* ptr = aValueStr.getStr(); - - bTestSuccess = false; - pTestReadData = NULL; - nTestReadDataSize = 0; - if( bOldDbAccess ) - { - if( bFirst ) - { - if( tableTest.open( 0,fileName.getStr(),0,DB_BTREE,DB_RDONLY,0644 ) ) - { - if( pFile != NULL ) - fprintf( pFile, "Cannot open database\n" ); - - break; - } - } - - Dbt key( static_cast< void* >( const_cast< sal_Char* >( aKeyStr.getStr() ) ), aKeyStr.getLength() ); - int err = tableTest.get( 0, &key, &data, 0 ); - if( err == 0 ) - { - bTestSuccess = true; - pTestReadData = static_cast< sal_Char* >( data.get_data() ); - nTestReadDataSize = data.get_size(); - } - } - else - { - bTestSuccess = getValueForKey( aKeyStr, aDBData ); - if( bTestSuccess ) - { - pTestReadData = aDBData.getData(); - nTestReadDataSize = aDBData.getSize(); - } - } - if( bFirst ) - { - afterfirsttime = osl_getGlobalTimer(); - bFirst = false; - } - int nError = 0; - if( bTestSuccess && pTestReadData != NULL ) - { - int nCmp = memcmp( ptr, pTestReadData, nValueLen ); - if( nCmp == 0 ) - ++nOkCount; - else - nError = 1; - - if( nValueLen != nTestReadDataSize ) - nError = 2; - } - else - nError = 3; - - if( nError != 0 ) - { - bSuccess = false; - ++nErrCount; - - if( pFile != NULL ) - { - fprintf( pFile, "ERROR, not found:\n" ); - testWriteKeyValue( pFile, rKeyValPair ); - fprintf( pFile, "\nError Code: %d\n", nError ); - } - } - } - tableTest.close( 0 ); - - sal_uInt32 endtime = osl_getGlobalTimer(); - double dDiffTime = (endtime-starttime) / 1000.0; - double dDiffFirstTime = (afterfirsttime-starttime) / 1000.0; - if( pFile != NULL ) - { - int nCount = avKeyValPair.size(); - fprintf( pFile, "%d key/values in total, read %d correctly, %d errors\n", - nCount, nOkCount, nErrCount ); - fprintf( pFile, "Time taken: %g s (First access %g s)\n", dDiffTime, dDiffFirstTime ); - fprintf( pFile, "Average time per access: %g s\n", dDiffTime / nCount ); - } - - if( pFile != NULL ) - fclose( pFile ); - - return bSuccess; -} - -#endif - - void DBHelp::createHashMap( bool bOptimizeForPerformance ) { releaseHashMap(); diff --git a/xmlhelp/source/cxxhelp/provider/db.hxx b/xmlhelp/source/cxxhelp/provider/db.hxx index da81a6d63c34..fdfd17148474 100644 --- a/xmlhelp/source/cxxhelp/provider/db.hxx +++ b/xmlhelp/source/cxxhelp/provider/db.hxx @@ -89,8 +89,6 @@ namespace berkeleydbproxy { }; -//#define TEST_DBHELP - class DBData { friend class DBHelp; @@ -150,10 +148,6 @@ namespace berkeleydbproxy { void createHashMap( bool bOptimizeForPerformance = false ); void releaseHashMap( void ); -#ifdef TEST_DBHELP - bool testAgainstDb( const rtl::OString& fileName, bool bOldDbAccess ); -#endif - bool getValueForKey( const rtl::OString& rKey, DBData& rValue ); bool startIteration( void ); |