mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-23 06:44:35 +00:00
Custom float-printing function.
This commit is contained in:
parent
8d5f4d7363
commit
36fb1f96e2
@ -280,29 +280,28 @@ const char* MemSizeToString( int64_t val )
|
|||||||
};
|
};
|
||||||
Unit unit;
|
Unit unit;
|
||||||
|
|
||||||
|
char* ptr;
|
||||||
if( aval < 10000ll * 1024 )
|
if( aval < 10000ll * 1024 )
|
||||||
{
|
{
|
||||||
sprintf( buf, "%.2f", val / 1024. );
|
ptr = PrintFloat( buf, buf+64, val / 1024., 2 );
|
||||||
unit = Unit::Kilobyte;
|
unit = Unit::Kilobyte;
|
||||||
}
|
}
|
||||||
else if( aval < 10000ll * 1024 * 1024 )
|
else if( aval < 10000ll * 1024 * 1024 )
|
||||||
{
|
{
|
||||||
sprintf( buf, "%.2f", val / ( 1024. * 1024 ) );
|
ptr = PrintFloat( buf, buf+64, val / ( 1024. * 1024 ), 2 );
|
||||||
unit = Unit::Megabyte;
|
unit = Unit::Megabyte;
|
||||||
}
|
}
|
||||||
else if( aval < 10000ll * 1024 * 1024 * 1024 )
|
else if( aval < 10000ll * 1024 * 1024 * 1024 )
|
||||||
{
|
{
|
||||||
sprintf( buf, "%.2f", val / ( 1024. * 1024 * 1024 ) );
|
ptr = PrintFloat( buf, buf+64, val / ( 1024. * 1024 * 1024 ), 2 );
|
||||||
unit = Unit::Gigabyte;
|
unit = Unit::Gigabyte;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf( buf, "%.2f", val / ( 1024. * 1024 * 1024 * 1024 ) );
|
ptr = PrintFloat( buf, buf+64, val / ( 1024. * 1024 * 1024 * 1024 ), 2 );
|
||||||
unit = Unit::Terabyte;
|
unit = Unit::Terabyte;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ptr = buf;
|
|
||||||
while( *ptr ) ptr++;
|
|
||||||
ptr--;
|
ptr--;
|
||||||
while( ptr >= buf && *ptr == '0' ) ptr--;
|
while( ptr >= buf && *ptr == '0' ) ptr--;
|
||||||
if( *ptr != '.' ) ptr++;
|
if( *ptr != '.' ) ptr++;
|
||||||
|
@ -1,9 +1,17 @@
|
|||||||
#ifndef __TRACYPRINT_HPP__
|
#ifndef __TRACYPRINT_HPP__
|
||||||
#define __TRACYPRINT_HPP__
|
#define __TRACYPRINT_HPP__
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static inline char* PrintFloat( char* begin, char* end, T value, int precision )
|
||||||
|
{
|
||||||
|
return begin + sprintf( begin, "%.*f", precision, value );
|
||||||
|
}
|
||||||
|
|
||||||
const char* TimeToString( int64_t ns );
|
const char* TimeToString( int64_t ns );
|
||||||
const char* RealToString( double val, bool separator );
|
const char* RealToString( double val, bool separator );
|
||||||
const char* MemSizeToString( int64_t val );
|
const char* MemSizeToString( int64_t val );
|
||||||
|
Loading…
Reference in New Issue
Block a user