当前位置: 首页>>代码示例>>C++>>正文


C++ FileStream::GetFileSize方法代码示例

本文整理汇总了C++中FileStream::GetFileSize方法的典型用法代码示例。如果您正苦于以下问题:C++ FileStream::GetFileSize方法的具体用法?C++ FileStream::GetFileSize怎么用?C++ FileStream::GetFileSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileStream的用法示例。


在下文中一共展示了FileStream::GetFileSize方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TestMSVCPreprocessedOutput

REGISTER_TESTS_END

// TestMSVCPreprocessedOutput
//------------------------------------------------------------------------------
void TestIncludeParser::TestMSVCPreprocessedOutput() const
{
    FileStream f;
    TEST_ASSERT( f.Open( "Data/TestIncludeParser/fbuildcore.msvc.ii", FileStream::READ_ONLY) )
    const size_t fileSize = (size_t)f.GetFileSize();
    AutoPtr< char > mem( (char *)ALLOC( fileSize + 1 ) );
    TEST_ASSERT( f.Read( mem.Get(), fileSize ) == fileSize );
    mem.Get()[ fileSize ] = 0;

    Timer t;

    const size_t repeatCount( 100 );
    for ( size_t i=0; i<repeatCount; ++i )
    {
        CIncludeParser parser;
        TEST_ASSERT( parser.ParseMSCL_Preprocessed( mem.Get(), fileSize ) );

        // check number of includes found to prevent future regressions
        const Array< AString > & includes = parser.GetIncludes();
        TEST_ASSERT( includes.GetSize() == 284 );
#ifdef DEBUG
        TEST_ASSERT( parser.GetNonUniqueCount() == 381 );
#endif
    }

    float time = t.GetElapsed();
    OUTPUT( "MSVC                 : %2.3fs (%2.1f MiB/sec)\n", time, ( (float)( fileSize * repeatCount / ( 1024.0f * 1024.0f ) ) / time ) );
}
开发者ID:dontnod,项目名称:fastbuild,代码行数:32,代码来源:TestIncludeParser.cpp

示例2: ms

// Load
//------------------------------------------------------------------------------
/*static*/ Object * ReflectionInfo::Load( const char * scopedName )
{
	AStackString<> fullPath;
	fullPath.Format( "Reflection\\%s.obj", scopedName );

	FileStream fs;
	if ( fs.Open( fullPath.Get(), FileStream::READ_ONLY ) == false )
	{
		return nullptr;
	}

	const size_t fileSize = (size_t)fs.GetFileSize();
	AutoPtr< char > mem( (char *)Alloc( fileSize + 1 ) );
	if ( fs.Read( mem.Get(), fileSize ) != fileSize )
	{
		return nullptr;
	}
	mem.Get()[ fileSize ] = 0;

	ConstMemoryStream ms( mem.Get(), fileSize + 1 );
	TextReader tr( ms );
	RefObject * refObject = tr.Read();
	ASSERT( !refObject || DynamicCast< Object >( refObject ) );

	return (Object *)refObject;
}
开发者ID:ClxS,项目名称:fastbuild,代码行数:28,代码来源:ReflectionInfo.cpp

示例3: TestClangMSExtensionsPreprocessedOutput

// TestClangMSExtensionsPreprocessedOutput
//------------------------------------------------------------------------------
void TestIncludeParser::TestClangMSExtensionsPreprocessedOutput() const
{
    FBuild fBuild; // needed fer CleanPath for relative dirs

    FileStream f;
    TEST_ASSERT( f.Open( "Data/TestIncludeParser/fbuildcore.clang.ms-extensions.ii", FileStream::READ_ONLY) )
    const size_t fileSize = (size_t)f.GetFileSize();
    AutoPtr< char > mem( (char *)ALLOC( fileSize + 1 ) );
    TEST_ASSERT( f.Read( mem.Get(), fileSize ) == fileSize );
    mem.Get()[ fileSize ] = 0;

    Timer t;

    const size_t repeatCount( 100 );
    for ( size_t i=0; i<repeatCount; ++i )
    {
        CIncludeParser parser;
        TEST_ASSERT( parser.ParseGCC_Preprocessed( mem.Get(), fileSize ) );

        // check number of includes found to prevent future regressions
        const Array< AString > & includes = parser.GetIncludes();
        TEST_ASSERT( includes.GetSize() == 285 );
#ifdef DEBUG
        TEST_ASSERT( parser.GetNonUniqueCount() == 4758 );
#endif
    }

    float time = t.GetElapsed();
    OUTPUT( "Clang (ms-extensions): %2.3fs (%2.1f MiB/sec)\n", time, ( (float)( fileSize * repeatCount / ( 1024.0f * 1024.0f ) ) / time ) );
}
开发者ID:dontnod,项目名称:fastbuild,代码行数:32,代码来源:TestIncludeParser.cpp

示例4: LoadShaderSource

/*!***********************************************************************
 @Function		LoadShader
 @Access		public 
 @Param			const char * c_pszName
 @Returns		bool
 @Description	
*************************************************************************/
bool ResourceManager::LoadShaderSource(const char* c_pszFilename, Uint32 uiType, Uint32& uiHandleOUT)
{
	FileStream* pFile = RESMAN->OpenFile(c_pszFilename);
	if(!pFile)
	{
		DebugLog("Failed to load shader: %s", c_pszFilename);
		return false;
	}

	Uint32 uiDataSize = pFile->GetFileSize();
	if(uiDataSize == 0)
	{
		DebugLog("Shader '%s' appears empty!", c_pszFilename);
		delete pFile;
		return false;
	}

	// Load the data file to memory.
	char* pszShaderSource = (char*)malloc(uiDataSize + 1);		// + 1 for NULL terminate.
	pFile->Read(pszShaderSource, uiDataSize, 1);
	pFile->Close();

	pszShaderSource[uiDataSize] = 0;

	// Create and compile the shader object
	uiHandleOUT = glCreateShader((GLenum)uiType);
	glShaderSource(uiHandleOUT, 1, (const char**)&pszShaderSource, NULL);

	DebugLog("------------ COMPILING: %s", c_pszFilename);
	glCompileShader(uiHandleOUT);

	// Test if compilation succeeded
	GLint ShaderCompiled;
	glGetShaderiv(uiHandleOUT, GL_COMPILE_STATUS, &ShaderCompiled);
	if (!ShaderCompiled)
	{
		int i32InfoLogLength, i32CharsWritten;
		glGetShaderiv(uiHandleOUT, GL_INFO_LOG_LENGTH, &i32InfoLogLength);
		char* pszInfoLog = new char[i32InfoLogLength];
		glGetShaderInfoLog(uiHandleOUT, i32InfoLogLength, &i32CharsWritten, pszInfoLog);
		
		DebugLog("Failed to compile shader: %s", pszInfoLog);
		
		delete [] pszInfoLog;
		glDeleteShader(uiHandleOUT);
	}

	free(pszShaderSource);
	
	delete pFile;
	
	return ShaderCompiled;
}
开发者ID:arron-h,项目名称:gravity-wars-redux,代码行数:60,代码来源:Resource.cpp

示例5: LoadFile

// LoadFile
//------------------------------------------------------------------------------
bool ToolManifest::LoadFile( const AString & fileName, void * & content, uint32_t & contentSize ) const
{
	// read the file into memory
	FileStream fs;
	if ( fs.Open( fileName.Get(), FileStream::READ_ONLY ) == false )
	{
		FLOG_ERROR( "Error opening file '%s' in Compiler ToolManifest\n", fileName.Get() );
		return false;
	}
	contentSize = (uint32_t)fs.GetFileSize();
	AutoPtr< void > mem( ALLOC( contentSize ) );
	if ( fs.Read( mem.Get(), contentSize ) != contentSize )
	{
		FLOG_ERROR( "Error reading file '%s' in Compiler ToolManifest\n", fileName.Get() );
		return false;
	}

	content = mem.Release();
	return true;
}
开发者ID:zhangf911,项目名称:fastbuild,代码行数:22,代码来源:ToolManifest.cpp

示例6: TestMSVC_ShowIncludesWithWarnings

// TestMSVC_ShowIncludesWithWarnings
//------------------------------------------------------------------------------
void TestIncludeParser::TestMSVC_ShowIncludesWithWarnings() const
{
    FBuild fb; // needed for CleanPath

    FileStream f;
    TEST_ASSERT( f.Open( "Data/TestIncludeParser/MSVC-ShowIncludes/WithWarnings.output", FileStream::READ_ONLY) )
    const size_t fileSize = (size_t)f.GetFileSize();
    AutoPtr< char > mem( (char *)ALLOC( fileSize + 1 ) );
    TEST_ASSERT( f.Read( mem.Get(), fileSize ) == fileSize );
    mem.Get()[ fileSize ] = 0;

    CIncludeParser parser;
    TEST_ASSERT( parser.ParseMSCL_Output( mem.Get(), fileSize ) );

    // check number of includes found to prevent future regressions
    const Array< AString > & includes = parser.GetIncludes();
    TEST_ASSERT( includes.GetSize() == 0 );
#ifdef DEBUG
    TEST_ASSERT( parser.GetNonUniqueCount() == 0 );
#endif
}
开发者ID:dontnod,项目名称:fastbuild,代码行数:23,代码来源:TestIncludeParser.cpp

示例7: GetCacheFileName

// Retrieve
//------------------------------------------------------------------------------
/*virtual*/ bool Cache::Retrieve( const AString & cacheId, void * & data, size_t & dataSize )
{
    data = nullptr;
    dataSize = 0;

    AStackString<> cacheFileName;
    GetCacheFileName( cacheId, cacheFileName );

    FileStream cacheFile;
    if ( cacheFile.Open( cacheFileName.Get(), FileStream::READ_ONLY ) )
    {
        const size_t cacheFileSize = (size_t)cacheFile.GetFileSize();
        AutoPtr< char > mem( (char *)ALLOC( cacheFileSize ) );
        if ( cacheFile.Read( mem.Get(), cacheFileSize ) == cacheFileSize )
        {
            dataSize = cacheFileSize;
            data = mem.Release();
            return true;
        }
    }

    return false;
}
开发者ID:dontnod,项目名称:fastbuild,代码行数:25,代码来源:Cache.cpp

示例8: tw

	/*static*/ bool ReflectionInfo::WriteDefinitions()
	{
		uint32_t numProblems = 0;

		const ReflectionInfo * ri = s_FirstReflectionInfo;
		for ( ; ri != nullptr; ri = ri->m_Next )
		{
			// ignore abstract classes
			if ( ri->IsAbstract() )
			{
				continue;
			}

			// Serialize a default instance to a MemoryStream 
			MemoryStream ms;
			{
				// Create and serialize default instance
				if ( ri->IsObject() )
				{
					RefObject * object = ri->CreateObject();
					{
						TextWriter tw( ms );
						tw.Write( object );
					}
					FDELETE( object );
				}
				else
				{
					ASSERT( ri->IsStruct() )
					Struct * str = ri->CreateStruct();
					{
						TextWriter tw( ms );
						tw.Write( str, ri );
					}
					FDELETE( str );
				}
			}

			AStackString<> fileName; 
			fileName.Format( "..\\Data\\Reflection\\.Definitions\\%s.definition", ri->GetTypeName() );

			// avoid writing file if not changed

			// Try to open existing file
			FileStream f;
			if ( f.Open( fileName.Get(), FileStream::READ_ONLY ) )
			{
				// read content
				const uint64_t fileSize = f.GetFileSize();
				if ( fileSize == ms.GetSize() )
				{
					AutoPtr< char > mem( (char *)Alloc( (size_t)fileSize ) );
					if ( f.Read( mem.Get(), (size_t)fileSize ) == fileSize )
					{
						if ( memcmp( mem.Get(), ms.GetData(), (size_t)fileSize ) == 0 )
						{
							continue; // definition has not changed
						}
					}
				}
				f.Close();
			}

			// Definition changed - try to save it

			int result = 0;
			AutoPtr< char > memOut;
			AutoPtr< char > memErr;
			uint32_t memOutSize;
			uint32_t memErrSize;

			// existing definition?
			if ( FileIO::FileExists( fileName.Get() ) )
			{
				// existing - need to open for edit?
				if ( FileIO::GetReadOnly( fileName ) )
				{
					AStackString<> args( "edit " );
					args += fileName;
					Process p;
					if ( p.Spawn( "p4", args.Get(), nullptr, nullptr ) )
					{
						p.ReadAllData( memOut, &memOutSize, memErr, &memErrSize );
						result = p.WaitForExit();
					}
				}
			}
			else
			{
				// new - open for add
				AStackString<> args( "add " );
				args += fileName;
				Process p;
				if ( p.Spawn( "p4", args.Get(), nullptr, nullptr ) )
				{
					p.ReadAllData( memOut, &memOutSize, memErr, &memErrSize );
					result = p.WaitForExit();
				}
			}

//.........这里部分代码省略.........
开发者ID:ClxS,项目名称:fastbuild,代码行数:101,代码来源:ReflectionInfo.cpp

示例9: ParseIncludeDirective

// ParseIncludeDirective
//------------------------------------------------------------------------------
bool BFFParser::ParseIncludeDirective( BFFIterator & iter )
{
	// Sanity check include depth to detect cyclic includes
	if ( s_Depth >= 128 )
	{
		Error::Error_1035_ExcessiveDepthComplexity( iter );
		return false;
	}

	// we expect a " quoted string
	if ( *iter != '"' )
	{
		Error::Error_1031_UnexpectedCharFollowingDirectiveName( iter, AStackString<>( "include" ), '"' ); 
		return false;
	}

	BFFIterator stringStart( iter );
	stringStart++; // first actual character

	// find end of string
	if ( iter.ParseToNext( '"' ) == false )
	{
		Error::Error_1012_UnexpectedEndOfFile( iter );
		return false;
	}

	// unescape and substitute variables
	AStackString<> include;
	if ( PerformVariableSubstitutions( stringStart, iter, include ) == false )
	{
		return false;
	}

	iter++; // skip closing quote before returning

	FLOG_INFO( "Including: %s\n", include.Get() );

	// open include

	// 1) Try current directory
	AStackString<> includeToUse;
	if (PathUtils::IsFullPath(include) == false)
	{
		const char * lastSlash = iter.GetFileName().FindLast( NATIVE_SLASH );
		lastSlash = lastSlash ? lastSlash : iter.GetFileName().FindLast( OTHER_SLASH );
		lastSlash = lastSlash ? ( lastSlash + 1 ): iter.GetFileName().Get(); // file only, truncate to empty
		includeToUse.Assign( iter.GetFileName().Get(), lastSlash );
	}
	includeToUse += include;
	AStackString<> includeToUseClean;
	NodeGraph::CleanPath( includeToUse, includeToUseClean );
	FileStream f;
	if ( f.Open( includeToUseClean.Get(), FileStream::READ_ONLY ) == false )
	{
		Error::Error_1032_UnableToOpenInclude( stringStart, includeToUseClean );
		return false;
	}

	// check if include uses "once" pragma
	if ( FBuild::Get().GetDependencyGraph().IsOneUseFile( includeToUseClean ) )
	{
		// already seen, and uses #once : don't include again
		return true;
	}

	uint64_t includeTimeStamp = FileIO::GetFileLastWriteTime( includeToUseClean );

	// read content of include
	const uint32_t fileSize = (uint32_t)f.GetFileSize();
	AutoPtr< char > mem( (char *)ALLOC( fileSize + 1 ) );
	if ( f.Read( mem.Get(), fileSize ) != fileSize )
	{
		Error::Error_1033_ErrorReadingInclude( stringStart, include, Env::GetLastErr() );
		return false;
	}
	mem.Get()[ fileSize ] = '\000'; // sentinel
	BFFParser parser;
	const bool pushStackFrame = false; // include is treated as if injected at this point
	return parser.Parse( mem.Get(), fileSize, includeToUseClean.Get(), includeTimeStamp, pushStackFrame ); 
}
开发者ID:ClxS,项目名称:fastbuild,代码行数:82,代码来源:BFFParser.cpp

示例10: sizeof

// ReadResults
//------------------------------------------------------------------------------
/*static*/ bool JobQueueRemote::ReadResults( Job * job )
{
	const ObjectNode * node = job->GetNode()->CastTo< ObjectNode >();
	const bool includePDB = (  node->IsUsingPDB() && ( job->IsLocal() == false ) );

	// main object
	FileStream fs;
	if ( fs.Open( node->GetName().Get() ) == false )
	{
		FLOG_ERROR( "File missing despite success: '%s'", node->GetName().Get() );
		return false;
	}
	uint32_t size = (uint32_t)fs.GetFileSize();
	uint32_t size2 = 0;

	// pdb file if present
	FileStream fs2;
	if ( includePDB )
	{
		AStackString<> pdbName;
		node->GetPDBName( pdbName );
		if ( fs2.Open( pdbName.Get() ) == false )
		{
			FLOG_ERROR( "File missing despite success: '%s'", pdbName.Get() );
			return false;
		}
		size2 = (uint32_t)fs2.GetFileSize();
	}

	// calc memory required
	size_t memSize = sizeof( uint32_t ); // write size of first file
	memSize += size;
	if ( includePDB )
	{
		memSize += sizeof( uint32_t ); // write size of second file
		memSize += size2;
	}

	// allocate entire buffer
	AutoPtr< char > mem( (char *)ALLOC( memSize ) );

	// write first file size
	*( (uint32_t *)mem.Get() ) = size;

	// read first file
	if ( fs.Read( mem.Get() + sizeof( uint32_t ), size ) != size )
	{
		FLOG_ERROR( "File read error for '%s'", node->GetName().Get() );
		return false;
	}

	if ( includePDB )
	{
		// write second file size
		*( (uint32_t *)( mem.Get() + sizeof( uint32_t ) + size ) ) = size2;

		// read second file
		if ( fs2.Read( mem.Get() + sizeof( uint32_t ) + size + sizeof( uint32_t ), size2 ) != size2 )
		{
			FLOG_ERROR( "File read error for '%s'", node->GetName().Get() );
			return false;
		}
	}

	// transfer data to job
	job->OwnData( mem.Release(), memSize );

	return true;
}
开发者ID:scott-nelson,项目名称:fastbuild,代码行数:71,代码来源:JobQueueRemote.cpp

示例11: if

// WriteIfDifferent
//------------------------------------------------------------------------------
/*static*/ bool ProjectGeneratorBase::WriteIfDifferent( const char * generatorId, const AString & content, const AString & fileName )
{
    bool needToWrite = false;

    FileStream old;
    if ( FBuild::Get().GetOptions().m_ForceCleanBuild )
    {
        needToWrite = true;
    }
    else if ( old.Open( fileName.Get(), FileStream::READ_ONLY ) == false )
    {
        needToWrite = true;
    }
    else
    {
        // files differ in size?
        size_t oldFileSize = (size_t)old.GetFileSize();
        if ( oldFileSize != content.GetLength() )
        {
            needToWrite = true;
        }
        else
        {
            // check content
            AutoPtr< char > mem( ( char *)ALLOC( oldFileSize ) );
            if ( old.Read( mem.Get(), oldFileSize ) != oldFileSize )
            {
                FLOG_ERROR( "%s - Failed to read '%s'", generatorId, fileName.Get() );
                return false;
            }

            // compare content
            if ( memcmp( mem.Get(), content.Get(), oldFileSize ) != 0 )
            {
                needToWrite = true;
            }
        }

        // ensure we are closed, so we can open again for write if needed
        old.Close();
    }

    // only save if missing or different
    if ( needToWrite == false )
    {
        return true; // nothing to do.
    }

    FLOG_BUILD( "%s: %s\n", generatorId, fileName.Get() );

    // ensure path exists (normally handled by framework, but Projects
    // are not necessarily a single file)
    if ( Node::EnsurePathExistsForFile( fileName ) == false )
    {
        FLOG_ERROR( "%s - Invalid path for '%s' (error: %u)", generatorId, fileName.Get(), Env::GetLastErr() );
        return false;
    }

    // actually write
    FileStream f;
    if ( !f.Open( fileName.Get(), FileStream::WRITE_ONLY ) )
    {
        FLOG_ERROR( "%s - Failed to open '%s' for write (error: %u)", generatorId, fileName.Get(), Env::GetLastErr() );
        return false;
    }
    if ( f.Write( content.Get(), content.GetLength() ) != content.GetLength() )
    {
        FLOG_ERROR( "%s - Error writing to '%s' (error: %u)", generatorId, fileName.Get(), Env::GetLastErr() );
        return false;
    }
    f.Close();

    return true;
}
开发者ID:liamkf,项目名称:fastbuild,代码行数:76,代码来源:ProjectGeneratorBase.cpp

示例12: Save

// Save
//------------------------------------------------------------------------------
bool SLNNode::Save( const AString & content, const AString & fileName ) const
{
    bool needToWrite = false;

    FileStream old;
    if ( FBuild::Get().GetOptions().m_ForceCleanBuild )
    {
        needToWrite = true;
    }
    else if ( old.Open( fileName.Get(), FileStream::READ_ONLY ) == false )
    {
        needToWrite = true;
    }
    else
    {
        // files differ in size?
        size_t oldFileSize = (size_t)old.GetFileSize();
        if ( oldFileSize != content.GetLength() )
        {
            needToWrite = true;
        }
        else
        {
            // check content
            AutoPtr< char > mem( ( char *)ALLOC( oldFileSize ) );
            if ( old.Read( mem.Get(), oldFileSize ) != oldFileSize )
            {
                FLOG_ERROR( "SLN - Failed to read '%s'", fileName.Get() );
                return false;
            }

            // compare content
            if ( memcmp( mem.Get(), content.Get(), oldFileSize ) != 0 )
            {
                needToWrite = true;
            }
        }

        // ensure we are closed, so we can open again for write if needed
        old.Close();
    }

    // only save if missing or ner
    if ( needToWrite == false )
    {
        return true; // nothing to do.
    }

    FLOG_BUILD( "SLN: %s\n", fileName.Get() );

    // actually write
    FileStream f;
    if ( !f.Open( fileName.Get(), FileStream::WRITE_ONLY ) )
    {
        FLOG_ERROR( "SLN - Failed to open '%s' for write (error: %u)", fileName.Get(), Env::GetLastErr() );
        return false;
    }
    if ( f.Write( content.Get(), content.GetLength() ) != content.GetLength() )
    {
        FLOG_ERROR( "SLN - Error writing to '%s' (error: %u)", fileName.Get(), Env::GetLastErr() );
        return false;
    }
    f.Close();

    return true;
}
开发者ID:hilbertdu,项目名称:fastbuild,代码行数:68,代码来源:SLNNode.cpp

示例13: CompressHelper

// CompressHelper
//------------------------------------------------------------------------------
void TestCompressor::CompressHelper( const char * fileName ) const
{
	// read some test data into a file
	AutoPtr< void > data;
	size_t dataSize;
	{
		FileStream fs;
		TEST_ASSERT( fs.Open( fileName ) );
		dataSize = (size_t)fs.GetFileSize();
		data = (char *)ALLOC( dataSize );
		TEST_ASSERT( (uint32_t)fs.Read( data.Get(), dataSize ) == dataSize );
	}

	OUTPUT( "File           : %s\n", fileName );
	OUTPUT( "Size           : %u\n", (uint32_t)dataSize );

	// compress the data to obtain size
	Compressor comp;
	comp.Compress( data.Get(), dataSize );
	size_t compressedSize = comp.GetResultSize();
	AutoPtr< char > compressedData( (char *)ALLOC( compressedSize ) );
	memcpy( compressedData.Get(), comp.GetResult(), compressedSize );
	float compressedPerc = ( (float)compressedSize / (float)dataSize ) * 100.0f;
	OUTPUT( "Compressed Size: %u (%2.1f%% of original)\n", (uint32_t)compressedSize, compressedPerc );

	// decompress to check we get original data back
	Compressor decomp;
	decomp.Decompress( compressedData.Get() );
	size_t uncompressedSize = decomp.GetResultSize();
	TEST_ASSERT( uncompressedSize == dataSize );
	for ( size_t i=0; i<uncompressedSize; ++i )
	{
		TEST_ASSERT( ( (char *)data.Get() )[ i ] == ( (char *)decomp.GetResult() )[ i ] );
	}

	// speed checks
	//--------------
	const size_t NUM_REPEATS( 100 );

	// compress the data several times to get more stable throughput value
	Timer t;
	for ( size_t i=0; i<NUM_REPEATS; ++i )
	{
		Compressor c;
		c.Compress( data.Get(), dataSize );
		TEST_ASSERT( c.GetResultSize() == compressedSize );
	}
	float compressTimeTaken = t.GetElapsed();
	double compressThroughputMBs = ( ( (double)dataSize / 1024.0 * (double)NUM_REPEATS ) / compressTimeTaken ) / 1024.0;
	OUTPUT( "     Comp Speed: %2.1f MB/s - %2.3fs (%u repeats)\n", (float)compressThroughputMBs, compressTimeTaken, NUM_REPEATS );
	
	// decompress the data
	Timer t2;
	for ( size_t i=0; i<NUM_REPEATS; ++i )
	{
		Compressor d;
		d.Decompress( compressedData.Get() );
		TEST_ASSERT( d.GetResultSize() == dataSize );
	}
	float decompressTimeTaken = t2.GetElapsed();
	double decompressThroughputMBs = ( ( (double)dataSize / 1024.0 * (double)NUM_REPEATS ) / decompressTimeTaken ) / 1024.0;
	OUTPUT( "   Decomp Speed: %2.1f MB/s - %2.3fs (%u repeats)\n", (float)decompressThroughputMBs, decompressTimeTaken, NUM_REPEATS );

	// time memcpy to compare with
	Timer t0;
	for ( size_t i=0; i<NUM_REPEATS; ++i )
	{
		char * mem = (char *)ALLOC( dataSize );
		memcpy( mem, data.Get(), dataSize );
		FREE( mem );
	}
	float memcpyTimeTaken = t0.GetElapsed();
	double memcpyThroughputMBs = ( ( (double)dataSize / 1024.0 * (double)NUM_REPEATS ) / memcpyTimeTaken ) / 1024.0;
	OUTPUT( "   MemCpy Speed: %2.1f MB/s - %2.3fs (%u repeats)\n", (float)memcpyThroughputMBs, memcpyTimeTaken, NUM_REPEATS );
}
开发者ID:ClxS,项目名称:fastbuild,代码行数:77,代码来源:TestCompressor.cpp


注:本文中的FileStream::GetFileSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。