You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
template<typename T>
size_t convert(char buf[], T value)
{
T i = value;
char* p = buf;
do
{
int lsd = static_cast<int>(i % 10);
i /= 10;
*p++ = zero[lsd];
} while (i != 0); //
if (value < 0)
{
*p++ = '-';
}
*p = '\0';
std::reverse(buf, p);
return p - buf;
}
i think some % and / is unncessary.They cause performence lose.
std perfomence betterat least on my machine :
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
wan ji zhuan shu ru fa le.
About convert int to char (in logstream):
muduo:
i think some % and / is unncessary.They cause performence lose.
std perfomence betterat least on my machine :
std:
here 's test
result(realease build):
Timer live for 20034.4 ms(muduo)
Timer live for 10197.1 ms(std)
un my laptop:
Timer live for 45365.2 ms
Timer live for 19382.4 ms
Beta Was this translation helpful? Give feedback.
All reactions