mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Extract source file caching functionality.
This commit is contained in:
parent
9ba7171c3d
commit
e086488928
@ -8705,14 +8705,7 @@ void Worker::CacheSource( const StringRef& str )
|
|||||||
const auto execTime = GetExecutableTime();
|
const auto execTime = GetExecutableTime();
|
||||||
if( SourceFileValid( file, execTime != 0 ? execTime : GetCaptureTime() ) )
|
if( SourceFileValid( file, execTime != 0 ? execTime : GetCaptureTime() ) )
|
||||||
{
|
{
|
||||||
FILE* f = fopen( file, "rb" );
|
CacheSourceFromFile( file );
|
||||||
fseek( f, 0, SEEK_END );
|
|
||||||
const auto sz = ftell( f );
|
|
||||||
fseek( f, 0, SEEK_SET );
|
|
||||||
auto src = (char*)m_slab.AllocBig( sz );
|
|
||||||
fread( src, 1, sz, f );
|
|
||||||
fclose( f );
|
|
||||||
m_data.sourceFileCache.emplace( file, MemoryBlock{ src, uint32_t( sz ) } );
|
|
||||||
}
|
}
|
||||||
else if( execTime != 0 )
|
else if( execTime != 0 )
|
||||||
{
|
{
|
||||||
@ -8721,6 +8714,18 @@ void Worker::CacheSource( const StringRef& str )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Worker::CacheSourceFromFile( const char* fn )
|
||||||
|
{
|
||||||
|
FILE* f = fopen( fn, "rb" );
|
||||||
|
fseek( f, 0, SEEK_END );
|
||||||
|
const auto sz = ftell( f );
|
||||||
|
fseek( f, 0, SEEK_SET );
|
||||||
|
auto src = (char*)m_slab.AllocBig( sz );
|
||||||
|
fread( src, 1, sz, f );
|
||||||
|
fclose( f );
|
||||||
|
m_data.sourceFileCache.emplace( fn, MemoryBlock{ src, uint32_t( sz ) } );
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t Worker::GetSourceFileCacheSize() const
|
uint64_t Worker::GetSourceFileCacheSize() const
|
||||||
{
|
{
|
||||||
uint64_t cnt = 0;
|
uint64_t cnt = 0;
|
||||||
|
@ -883,6 +883,7 @@ private:
|
|||||||
const ContextSwitch* const GetContextSwitchDataImpl( uint64_t thread );
|
const ContextSwitch* const GetContextSwitchDataImpl( uint64_t thread );
|
||||||
|
|
||||||
void CacheSource( const StringRef& str );
|
void CacheSource( const StringRef& str );
|
||||||
|
void CacheSourceFromFile( const char* fn );
|
||||||
|
|
||||||
tracy_force_inline Vector<short_ptr<ZoneEvent>>& GetZoneChildrenMutable( int32_t idx ) { return m_data.zoneChildren[idx]; }
|
tracy_force_inline Vector<short_ptr<ZoneEvent>>& GetZoneChildrenMutable( int32_t idx ) { return m_data.zoneChildren[idx]; }
|
||||||
tracy_force_inline Vector<short_ptr<GpuEvent>>& GetGpuChildrenMutable( int32_t idx ) { return m_data.gpuChildren[idx]; }
|
tracy_force_inline Vector<short_ptr<GpuEvent>>& GetGpuChildrenMutable( int32_t idx ) { return m_data.gpuChildren[idx]; }
|
||||||
|
Loading…
Reference in New Issue
Block a user