mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
CPU usage retrieval.
This commit is contained in:
@@ -1147,6 +1147,7 @@ void Profiler::Worker()
|
||||
int keepAlive = 0;
|
||||
for(;;)
|
||||
{
|
||||
ProcessSysTime();
|
||||
const auto status = Dequeue( token );
|
||||
const auto serialStatus = DequeueSerial();
|
||||
if( status == ConnectionLost || serialStatus == ConnectionLost )
|
||||
@@ -1859,6 +1860,26 @@ void Profiler::SendCallstack( int depth, uint64_t thread, const char* skipBefore
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef TRACY_HAS_SYSTIME
|
||||
void Profiler::ProcessSysTime()
|
||||
{
|
||||
auto t = std::chrono::high_resolution_clock::now().time_since_epoch().count();
|
||||
if( t - m_sysTimeLast > 100000000 ) // 100 ms
|
||||
{
|
||||
m_sysTimeLast = t;
|
||||
|
||||
Magic magic;
|
||||
auto token = GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
MemWrite( &item->hdr.type, QueueType::SysTimeReport );
|
||||
MemWrite( &item->sysTime.time, GetTime() );
|
||||
MemWrite( &item->sysTime.sysTime, m_sysTime.Get() );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user