mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-12 19:31:47 +00:00
Allow specifying FileWrite compression level.
Note that extreme compression level is not exposed in the update utility. % time update.exe long.tracy out.tracy long.tracy (0.3.201) -> out.tracy (0.3.204) update.exe long.tracy 0,00s user 0,00s system 0% cpu 13,464 total % time update.exe --hc long.tracy outhc.tracy long.tracy (0.3.201) -> outhc.tracy (0.3.204) update.exe --hc long.trac 0,00s user 0,00s system 0% cpu 3:46,23 total % ls -l long.tracy out* -rw-r--r-- 1 wolf Brak 1621546031 07-30 22:51 long.tracy -rw-r--r-- 1 wolf Brak 1621579467 08-26 16:44 out.tracy -rw-r--r-- 1 wolf Brak 1397610127 08-26 16:48 outhc.tracy
This commit is contained in:
parent
39fd3b3a6f
commit
a5b99b54c8
@ -2,6 +2,7 @@
|
|||||||
#define __TRACYFILEWRITE_HPP__
|
#define __TRACYFILEWRITE_HPP__
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -16,10 +17,17 @@ namespace tracy
|
|||||||
class FileWrite
|
class FileWrite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static FileWrite* Open( const char* fn, bool hc = false )
|
enum class Compression
|
||||||
|
{
|
||||||
|
Fast,
|
||||||
|
Slow,
|
||||||
|
Extreme
|
||||||
|
};
|
||||||
|
|
||||||
|
static FileWrite* Open( const char* fn, Compression comp = Compression::Fast )
|
||||||
{
|
{
|
||||||
auto f = fopen( fn, "wb" );
|
auto f = fopen( fn, "wb" );
|
||||||
return f ? new FileWrite( f, hc ) : nullptr;
|
return f ? new FileWrite( f, comp ) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
~FileWrite()
|
~FileWrite()
|
||||||
@ -47,7 +55,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FileWrite( FILE* f, bool hc )
|
FileWrite( FILE* f, Compression comp )
|
||||||
: m_stream( nullptr )
|
: m_stream( nullptr )
|
||||||
, m_streamHC( nullptr )
|
, m_streamHC( nullptr )
|
||||||
, m_file( f )
|
, m_file( f )
|
||||||
@ -55,13 +63,21 @@ private:
|
|||||||
, m_second( m_bufData[1] )
|
, m_second( m_bufData[1] )
|
||||||
, m_offset( 0 )
|
, m_offset( 0 )
|
||||||
{
|
{
|
||||||
if( hc )
|
switch( comp )
|
||||||
{
|
|
||||||
m_streamHC = LZ4_createStreamHC();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
case Compression::Fast:
|
||||||
m_stream = LZ4_createStream();
|
m_stream = LZ4_createStream();
|
||||||
|
break;
|
||||||
|
case Compression::Slow:
|
||||||
|
m_streamHC = LZ4_createStreamHC();
|
||||||
|
break;
|
||||||
|
case Compression::Extreme:
|
||||||
|
m_streamHC = LZ4_createStreamHC();
|
||||||
|
LZ4_resetStreamHC( m_streamHC, LZ4HC_CLEVEL_OPT_MIN );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert( false );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fwrite( Lz4Header, 1, sizeof( Lz4Header ), m_file );
|
fwrite( Lz4Header, 1, sizeof( Lz4Header ), m_file );
|
||||||
|
@ -52,7 +52,7 @@ int main( int argc, char** argv )
|
|||||||
{
|
{
|
||||||
tracy::Worker worker( *f );
|
tracy::Worker worker( *f );
|
||||||
|
|
||||||
auto w = std::unique_ptr<tracy::FileWrite>( tracy::FileWrite::Open( output, hc ) );
|
auto w = std::unique_ptr<tracy::FileWrite>( tracy::FileWrite::Open( output, hc ? tracy::FileWrite::Compression::Slow : tracy::FileWrite::Compression::Fast ) );
|
||||||
if( !w )
|
if( !w )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Cannot open output file!\n" );
|
fprintf( stderr, "Cannot open output file!\n" );
|
||||||
|
Loading…
Reference in New Issue
Block a user