diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 649190e0..0163874e 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -325,6 +325,28 @@ uint64_t View::GetLastTime() const return last; } +const char* View::TimeToString( uint64_t ns ) const +{ + static char buf[64]; + if( ns < 1000 ) + { + sprintf( buf, "%i ns", ns ); + } + else if( ns < 1000 * 1000 ) + { + sprintf( buf, "%.2f us", ns / 1024.f ); + } + else if( ns < 1000 * 1000 * 1000 ) + { + sprintf( buf, "%.2f ms", ns / ( 1024.f * 1024 ) ); + } + else + { + sprintf( buf, "%.2f s", ns / ( 1024.f * 1024 * 1024 ) ); + } + return buf; +} + void View::Draw() { s_instance->DrawImpl(); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 2032c55d..7d73014f 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -50,6 +50,7 @@ private: uint64_t GetFrameTime( size_t idx ) const; uint64_t GetLastTime() const; + const char* TimeToString( uint64_t ns ) const; void DrawImpl(); void DrawFrames();