mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 07:54:36 +00:00
Support formatting of negative time.
This commit is contained in:
parent
36ffaec1df
commit
29d5b8d4e9
@ -523,7 +523,7 @@ Vector<Event*>& View::GetParentVector( const Event& ev )
|
||||
}
|
||||
}
|
||||
|
||||
const char* View::TimeToString( uint64_t ns ) const
|
||||
const char* View::TimeToString( int64_t ns ) const
|
||||
{
|
||||
enum { Pool = 4 };
|
||||
static char bufpool[Pool][64];
|
||||
@ -531,27 +531,34 @@ const char* View::TimeToString( uint64_t ns ) const
|
||||
char* buf = bufpool[bufsel];
|
||||
bufsel = ( bufsel + 1 ) % Pool;
|
||||
|
||||
const char* sign = "";
|
||||
if( ns < 0 )
|
||||
{
|
||||
sign = "-";
|
||||
ns = -ns;
|
||||
}
|
||||
|
||||
if( ns < 1000 )
|
||||
{
|
||||
sprintf( buf, "%" PRIu64 " ns", ns );
|
||||
sprintf( buf, "%s%" PRIu64 " ns", sign, ns );
|
||||
}
|
||||
else if( ns < 1000ull * 1000 )
|
||||
{
|
||||
sprintf( buf, "%.2f us", ns / 1000. );
|
||||
sprintf( buf, "%s%.2f us", sign, ns / 1000. );
|
||||
}
|
||||
else if( ns < 1000ull * 1000 * 1000 )
|
||||
{
|
||||
sprintf( buf, "%.2f ms", ns / ( 1000. * 1000. ) );
|
||||
sprintf( buf, "%s%.2f ms", sign, ns / ( 1000. * 1000. ) );
|
||||
}
|
||||
else if( ns < 1000ull * 1000 * 1000 * 60 )
|
||||
{
|
||||
sprintf( buf, "%.2f s", ns / ( 1000. * 1000. * 1000. ) );
|
||||
sprintf( buf, "%s%.2f s", sign, ns / ( 1000. * 1000. * 1000. ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto m = ns / ( 1000ull * 1000 * 1000 * 60 );
|
||||
const auto s = ns - m * ( 1000ull * 1000 * 1000 * 60 );
|
||||
sprintf( buf, "%" PRIu64 ":%04.1f", m, s / ( 1000. * 1000. * 1000. ) );
|
||||
sprintf( buf, "%s%" PRIu64 ":%04.1f", sign, m, s / ( 1000. * 1000. * 1000. ) );
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ private:
|
||||
uint64_t GetLastTime() const;
|
||||
int64_t GetZoneEnd( const Event& ev ) const;
|
||||
Vector<Event*>& GetParentVector( const Event& ev );
|
||||
const char* TimeToString( uint64_t ns ) const;
|
||||
const char* TimeToString( int64_t ns ) const;
|
||||
const char* GetString( uint64_t ptr ) const;
|
||||
const char* GetThreadString( uint64_t id ) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user