1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-28 20:23:51 +00:00

Store sampling period.

This commit is contained in:
Bartosz Taudul 2020-02-25 23:08:52 +01:00
parent 3402d16548
commit 2b7f5091f1
4 changed files with 7 additions and 4 deletions

View File

@ -1024,6 +1024,7 @@ Profiler::Profiler()
, m_broadcast( nullptr )
, m_noExit( false )
, m_zoneId( 1 )
, m_samplingPeriod( 0 )
, m_stream( LZ4_createStream() )
, m_buffer( (char*)tracy_malloc( TargetFrameSize*3 ) )
, m_bufferOffset( 0 )
@ -1072,7 +1073,7 @@ Profiler::Profiler()
new(s_compressThread) Thread( LaunchCompressWorker, this );
#ifdef TRACY_HAS_SYSTEM_TRACING
if( SysTraceStart() )
if( SysTraceStart( m_samplingPeriod ) )
{
s_sysTraceThread = (Thread*)tracy_malloc( sizeof( Thread ) );
new(s_sysTraceThread) Thread( SysTraceWorker, nullptr );

View File

@ -619,6 +619,7 @@ private:
UdpBroadcast* m_broadcast;
bool m_noExit;
std::atomic<uint32_t> m_zoneId;
int64_t m_samplingPeriod;
uint64_t m_threadCtx;
int64_t m_refTimeThread;

View File

@ -160,7 +160,7 @@ void WINAPI EventRecordCallback( PEVENT_RECORD record )
}
}
bool SysTraceStart()
bool SysTraceStart( int64_t& samplingPeriod )
{
s_pid = GetCurrentProcessId();
@ -191,6 +191,7 @@ bool SysTraceStart()
interval.Interval = 1250; // 8 kHz
const auto intervalStatus = TraceSetInformation( 0, TraceSampledProfileIntervalInfo, &interval, sizeof( interval ) );
if( intervalStatus != ERROR_SUCCESS ) return false;
samplingPeriod = 125*1000;
}
const auto psz = sizeof( EVENT_TRACE_PROPERTIES ) + sizeof( KERNEL_LOGGER_NAME );
@ -523,7 +524,7 @@ void SysTraceInjectPayload()
}
#endif
bool SysTraceStart()
bool SysTraceStart( int64_t& samplingPeriod )
{
if( !TraceWrite( TracingOn, sizeof( TracingOn ), "0", 2 ) ) return false;
if( !TraceWrite( CurrentTracer, sizeof( CurrentTracer ), "nop", 4 ) ) return false;

View File

@ -12,7 +12,7 @@
namespace tracy
{
bool SysTraceStart();
bool SysTraceStart( int64_t& samplingPeriod );
void SysTraceStop();
void SysTraceWorker( void* ptr );