mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Don't send CPU usage data when there's no readings.
This commit is contained in:
parent
963d2b3ca8
commit
b89db6e926
@ -1869,16 +1869,20 @@ 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;
|
||||
auto sysTime = m_sysTime.Get();
|
||||
if( sysTime >= 0 )
|
||||
{
|
||||
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 );
|
||||
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, sysTime );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -78,10 +78,10 @@ float SysTime::Get()
|
||||
const auto diffUsed = used - oldUsed;
|
||||
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
return diffUsed == 0 ? 0 : ( diffUsed - diffIdle ) * 100.f / diffUsed;
|
||||
return diffUsed == 0 ? -1 : ( diffUsed - diffIdle ) * 100.f / diffUsed;
|
||||
#elif defined __linux__ || defined __APPLE__
|
||||
const auto total = diffUsed + diffIdle;
|
||||
return total == 0 ? 0 : diffUsed * 100.f / total;
|
||||
return total == 0 ? -1 : diffUsed * 100.f / total;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user