Open
Description
As mentioned in the title, utf16_to_utf8 costs a lot time. For 1 MB utf16 string, it would costs 5 seconds on Win10 with E5-1620 machine. And the costs increased by linear, 11 seconds for 2 MB, 22 seconds for 4 MB e.g.
Here is the sample code:
#include "stdafx.h"
#include "cpprest/asyncrt_utils.h"
int main()
{
int length = 1 * 1024 * 1024;
utility::datetime start = utility::datetime::utc_now();
utility::string_t text(length, _XPLATSTR('C'));
auto content = utility::conversions::utf16_to_utf8(text);
utility::datetime end = utility::datetime::utc_now();
ucout << "String Length: " << length << std::endl;
ucout << "Time Cost: " << end - start << " second(s)" << std::endl;
return 0;
}
Is there a better way to do the conversion? Could the performance of utf16_to_utf8 be improved?
Metadata
Metadata
Assignees
Labels
No labels