mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Move file compression enum out of FileWrite.
This commit is contained in:
parent
07c6e12dbf
commit
9dea830f98
@ -50,7 +50,7 @@ int main( int argc, char** argv )
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tracy::FileWrite::Compression clev = tracy::FileWrite::Compression::Fast;
|
tracy::FileCompression clev = tracy::FileCompression::Fast;
|
||||||
|
|
||||||
if( argc != 3 ) Usage();
|
if( argc != 3 ) Usage();
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tracy::FileWrite::Compression clev = tracy::FileWrite::Compression::Fast;
|
tracy::FileCompression clev = tracy::FileCompression::Fast;
|
||||||
|
|
||||||
if (argc != 3)
|
if (argc != 3)
|
||||||
Usage();
|
Usage();
|
||||||
|
@ -551,7 +551,7 @@ bool View::Draw()
|
|||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
static FileWrite::Compression comp = FileWrite::Compression::Fast;
|
static FileCompression comp = FileCompression::Fast;
|
||||||
static int zlvl = 6;
|
static int zlvl = 6;
|
||||||
ImGui::TextUnformatted( ICON_FA_FILE_ZIPPER " Trace compression" );
|
ImGui::TextUnformatted( ICON_FA_FILE_ZIPPER " Trace compression" );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -560,7 +560,7 @@ bool View::Draw()
|
|||||||
int idx = 0;
|
int idx = 0;
|
||||||
while( CompressionName[idx] )
|
while( CompressionName[idx] )
|
||||||
{
|
{
|
||||||
if( ImGui::RadioButton( CompressionName[idx], (int)comp == idx ) ) comp = (FileWrite::Compression)idx;
|
if( ImGui::RadioButton( CompressionName[idx], (int)comp == idx ) ) comp = (FileCompression)idx;
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
TextDisabledUnformatted( CompressionDesc[idx] );
|
TextDisabledUnformatted( CompressionDesc[idx] );
|
||||||
idx++;
|
idx++;
|
||||||
@ -572,7 +572,7 @@ bool View::Draw()
|
|||||||
ImGui::Indent();
|
ImGui::Indent();
|
||||||
if( ImGui::SliderInt( "##zstd", &zlvl, 1, 22, "%d", ImGuiSliderFlags_AlwaysClamp ) )
|
if( ImGui::SliderInt( "##zstd", &zlvl, 1, 22, "%d", ImGuiSliderFlags_AlwaysClamp ) )
|
||||||
{
|
{
|
||||||
comp = FileWrite::Compression::Zstd;
|
comp = FileCompression::Zstd;
|
||||||
}
|
}
|
||||||
ImGui::Unindent();
|
ImGui::Unindent();
|
||||||
|
|
||||||
@ -1340,7 +1340,7 @@ void View::DrawSourceTooltip( const char* filename, uint32_t srcline, int before
|
|||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool View::Save( const char* fn, FileWrite::Compression comp, int zlevel, bool buildDict )
|
bool View::Save( const char* fn, FileCompression comp, int zlevel, bool buildDict )
|
||||||
{
|
{
|
||||||
std::unique_ptr<FileWrite> f( FileWrite::Open( fn, comp, zlevel ) );
|
std::unique_ptr<FileWrite> f( FileWrite::Open( fn, comp, zlevel ) );
|
||||||
if( !f ) return false;
|
if( !f ) return false;
|
||||||
|
@ -367,7 +367,7 @@ private:
|
|||||||
void CalcZoneTimeDataImpl( const V& children, const ContextSwitch* ctx, unordered_flat_map<int16_t, ZoneTimeData>& data, int64_t& ztime );
|
void CalcZoneTimeDataImpl( const V& children, const ContextSwitch* ctx, unordered_flat_map<int16_t, ZoneTimeData>& data, int64_t& ztime );
|
||||||
|
|
||||||
void SetPlaybackFrame( uint32_t idx );
|
void SetPlaybackFrame( uint32_t idx );
|
||||||
bool Save( const char* fn, FileWrite::Compression comp, int zlevel, bool buildDict );
|
bool Save( const char* fn, FileCompression comp, int zlevel, bool buildDict );
|
||||||
|
|
||||||
void Attention( bool& alreadyDone );
|
void Attention( bool& alreadyDone );
|
||||||
void UpdateTitle();
|
void UpdateTitle();
|
||||||
|
@ -20,18 +20,18 @@
|
|||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
|
enum class FileCompression
|
||||||
|
{
|
||||||
|
Fast,
|
||||||
|
Slow,
|
||||||
|
Extreme,
|
||||||
|
Zstd
|
||||||
|
};
|
||||||
|
|
||||||
class FileWrite
|
class FileWrite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class Compression
|
static FileWrite* Open( const char* fn, FileCompression comp = FileCompression::Fast, int level = 1 )
|
||||||
{
|
|
||||||
Fast,
|
|
||||||
Slow,
|
|
||||||
Extreme,
|
|
||||||
Zstd
|
|
||||||
};
|
|
||||||
|
|
||||||
static FileWrite* Open( const char* fn, Compression comp = Compression::Fast, int level = 1 )
|
|
||||||
{
|
{
|
||||||
auto f = fopen( fn, "wb" );
|
auto f = fopen( fn, "wb" );
|
||||||
return f ? new FileWrite( f, comp, level ) : nullptr;
|
return f ? new FileWrite( f, comp, level ) : nullptr;
|
||||||
@ -67,7 +67,7 @@ public:
|
|||||||
std::pair<size_t, size_t> GetCompressionStatistics() const { return std::make_pair( m_srcBytes, m_dstBytes ); }
|
std::pair<size_t, size_t> GetCompressionStatistics() const { return std::make_pair( m_srcBytes, m_dstBytes ); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FileWrite( FILE* f, Compression comp, int level )
|
FileWrite( FILE* f, FileCompression comp, int level )
|
||||||
: m_stream( nullptr )
|
: m_stream( nullptr )
|
||||||
, m_streamHC( nullptr )
|
, m_streamHC( nullptr )
|
||||||
, m_streamZstd( nullptr )
|
, m_streamZstd( nullptr )
|
||||||
@ -80,17 +80,17 @@ private:
|
|||||||
{
|
{
|
||||||
switch( comp )
|
switch( comp )
|
||||||
{
|
{
|
||||||
case Compression::Fast:
|
case FileCompression::Fast:
|
||||||
m_stream = LZ4_createStream();
|
m_stream = LZ4_createStream();
|
||||||
break;
|
break;
|
||||||
case Compression::Slow:
|
case FileCompression::Slow:
|
||||||
m_streamHC = LZ4_createStreamHC();
|
m_streamHC = LZ4_createStreamHC();
|
||||||
break;
|
break;
|
||||||
case Compression::Extreme:
|
case FileCompression::Extreme:
|
||||||
m_streamHC = LZ4_createStreamHC();
|
m_streamHC = LZ4_createStreamHC();
|
||||||
LZ4_resetStreamHC( m_streamHC, LZ4HC_CLEVEL_MAX );
|
LZ4_resetStreamHC( m_streamHC, LZ4HC_CLEVEL_MAX );
|
||||||
break;
|
break;
|
||||||
case Compression::Zstd:
|
case FileCompression::Zstd:
|
||||||
m_streamZstd = ZSTD_createCStream();
|
m_streamZstd = ZSTD_createCStream();
|
||||||
ZSTD_CCtx_setParameter( m_streamZstd, ZSTD_c_compressionLevel, level );
|
ZSTD_CCtx_setParameter( m_streamZstd, ZSTD_c_compressionLevel, level );
|
||||||
ZSTD_CCtx_setParameter( m_streamZstd, ZSTD_c_contentSizeFlag, 0 );
|
ZSTD_CCtx_setParameter( m_streamZstd, ZSTD_c_contentSizeFlag, 0 );
|
||||||
@ -100,7 +100,7 @@ private:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( comp == Compression::Zstd )
|
if( comp == FileCompression::Zstd )
|
||||||
{
|
{
|
||||||
fwrite( ZstdHeader, 1, sizeof( ZstdHeader ), m_file );
|
fwrite( ZstdHeader, 1, sizeof( ZstdHeader ), m_file );
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ int main( int argc, char** argv )
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tracy::FileWrite::Compression clev = tracy::FileWrite::Compression::Fast;
|
tracy::FileCompression clev = tracy::FileCompression::Fast;
|
||||||
uint32_t events = tracy::EventType::All;
|
uint32_t events = tracy::EventType::All;
|
||||||
int zstdLevel = 1;
|
int zstdLevel = 1;
|
||||||
bool buildDict = false;
|
bool buildDict = false;
|
||||||
@ -64,13 +64,13 @@ int main( int argc, char** argv )
|
|||||||
switch( c )
|
switch( c )
|
||||||
{
|
{
|
||||||
case 'h':
|
case 'h':
|
||||||
clev = tracy::FileWrite::Compression::Slow;
|
clev = tracy::FileCompression::Slow;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
clev = tracy::FileWrite::Compression::Extreme;
|
clev = tracy::FileCompression::Extreme;
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
clev = tracy::FileWrite::Compression::Zstd;
|
clev = tracy::FileCompression::Zstd;
|
||||||
zstdLevel = atoi( optarg );
|
zstdLevel = atoi( optarg );
|
||||||
if( zstdLevel > ZSTD_maxCLevel() || zstdLevel < ZSTD_minCLevel() )
|
if( zstdLevel > ZSTD_maxCLevel() || zstdLevel < ZSTD_minCLevel() )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user