mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-23 06:44:35 +00:00
Common percentage printing function.
This commit is contained in:
parent
11aedf2b27
commit
c1ed44bd35
@ -396,6 +396,19 @@ void SourceView::Render( const Worker& worker )
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintPercentage( float val )
|
||||
{
|
||||
char tmp[16];
|
||||
auto end = PrintFloat( tmp, tmp+16, val, 2 );
|
||||
memcpy( end, "%", 2 );
|
||||
end++;
|
||||
const auto sz = end - tmp;
|
||||
char buf[16];
|
||||
memset( buf, ' ', 7-sz );
|
||||
memcpy( buf + 7 - sz, tmp, sz+1 );
|
||||
ImGui::TextUnformatted( buf );
|
||||
}
|
||||
|
||||
void SourceView::RenderLine( const Line& line, int lineNum, uint32_t ipcnt, uint32_t iptotal )
|
||||
{
|
||||
const auto ty = ImGui::GetFontSize();
|
||||
@ -415,15 +428,7 @@ void SourceView::RenderLine( const Line& line, int lineNum, uint32_t ipcnt, uint
|
||||
}
|
||||
else
|
||||
{
|
||||
char tmp[16];
|
||||
auto end = PrintFloat( tmp, tmp+16, 100.f * ipcnt / iptotal, 2 );
|
||||
memcpy( end, "%", 2 );
|
||||
end++;
|
||||
const auto sz = end - tmp;
|
||||
char buf[16];
|
||||
memset( buf, ' ', 7-sz );
|
||||
memcpy( buf + 7 - sz, tmp, sz+1 );
|
||||
ImGui::TextUnformatted( buf );
|
||||
PrintPercentage( 100.f * ipcnt / iptotal );
|
||||
}
|
||||
ImGui::SameLine( 0, ty );
|
||||
}
|
||||
@ -463,15 +468,7 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
|
||||
}
|
||||
else
|
||||
{
|
||||
char tmp[16];
|
||||
auto end = PrintFloat( tmp, tmp+16, 100.f * ipcnt / iptotal, 2 );
|
||||
memcpy( end, "%", 2 );
|
||||
end++;
|
||||
const auto sz = end - tmp;
|
||||
char buf[16];
|
||||
memset( buf, ' ', 7-sz );
|
||||
memcpy( buf + 7 - sz, tmp, sz+1 );
|
||||
ImGui::TextUnformatted( buf );
|
||||
PrintPercentage( 100.f * ipcnt / iptotal );
|
||||
}
|
||||
ImGui::SameLine( 0, ty );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user