News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

UTF8 performance

Started by Biterider, April 03, 2020, 12:41:17 AM

Previous topic - Next topic

LiaoMi

-----------------------------------------------------------
Preparing the test...
RANGE = 0
Testing WideToUTF8...
FAILED  Fastest run     WideToUTF8: 375 ticks, WideCharToMultiByte: 421 ticks = 10% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 515 ticks, MultiByteToWideChar: 672 ticks = 23% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 1
Testing WideToUTF8...
FAILED  Fastest run     WideToUTF8: 1312 ticks, WideCharToMultiByte: 1813 ticks = 27% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 2093 ticks, MultiByteToWideChar: 2672 ticks = 21% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 2
Testing WideToUTF8...
FAILED  Fastest run     WideToUTF8: 656 ticks, WideCharToMultiByte: 828 ticks = 20% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 1047 ticks, MultiByteToWideChar: 1297 ticks = 19% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 3
Testing WideToUTF8...
FAILED  Fastest run     WideToUTF8: 812 ticks, WideCharToMultiByte: 1094 ticks = 25% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 968 ticks, MultiByteToWideChar: 1343 ticks = 27% faster
Ready
Press any key to continue ...

Biterider

@Siekmanski/LiaoMi: sorry, I uploaded a wrong version of the exe  :sad:
I uploaded the correct code now. Timings should be correct.

Biterider

mineiro

good job, that explains the reason, thanks.

$ wine PerformanceTest.exe
-----------------------------------------------------------
Preparing the test...
RANGE = 0
Testing WideToUTF8...
FAILED  Fastest run     WideToUTF8: 358 ticks, WideCharToMultiByte: 539 ticks = 33% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 490 ticks, MultiByteToWideChar: 674 ticks = 27% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 1
Testing WideToUTF8...
FAILED  Fastest run     WideToUTF8: 1238 ticks, WideCharToMultiByte: 1761 ticks = 29% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 1990 ticks, MultiByteToWideChar: 3006 ticks = 33% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 2
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 621 ticks, WideCharToMultiByte: 882 ticks = 29% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 984 ticks, MultiByteToWideChar: 1497 ticks = 34% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 3
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 727 ticks, WideCharToMultiByte: 3094 ticks = 76% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 857 ticks, MultiByteToWideChar: 903 ticks = 5% faster
Ready
Press any key to continue ...
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

Siekmanski

 :thumbsup:

-----------------------------------------------------------
Preparing the test...
RANGE = 0
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 421 ticks, WideCharToMultiByte: 453 ticks = 7% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 547 ticks, MultiByteToWideChar: 750 ticks = 27% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 1
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 1359 ticks, WideCharToMultiByte: 1843 ticks = 26% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 2172 ticks, MultiByteToWideChar: 3234 ticks = 32% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 2
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 671 ticks, WideCharToMultiByte: 797 ticks = 15% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 1062 ticks, MultiByteToWideChar: 1593 ticks = 33% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 3
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 1203 ticks, WideCharToMultiByte: 1203 ticks = 0% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 1187 ticks, MultiByteToWideChar: 1593 ticks = 25% faster
Ready
Press any key to continue ...
Creative coders use backward thinking techniques as a strategy.

Biterider

Hi all
For the sake of completeness, I have limited the performance test to strings of 16 code points long, which should be the most common case.

The results on my machine looks like:

Large test:
-----------------------------------------------------------
Preparing the test...
RANGE = 0
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 343 ticks, WideCharToMultiByte: 390 ticks = 13% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 468 ticks, MultiByteToWideChar: 563 ticks = 20% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 1
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 1203 ticks, WideCharToMultiByte: 1656 ticks = 37% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 1938 ticks, MultiByteToWideChar: 2297 ticks = 18% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 2
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 593 ticks, WideCharToMultiByte: 750 ticks = 26% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 953 ticks, MultiByteToWideChar: 1141 ticks = 19% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 3
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 719 ticks, WideCharToMultiByte: 1000 ticks = 39% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 859 ticks, MultiByteToWideChar: 1156 ticks = 34% faster
Ready
Press any key to continue ...


Short test:
-----------------------------------------------------------
Preparing the test...
RANGE = 0
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 625 ticks, WideCharToMultiByte: 1062 ticks = 69% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 750 ticks, MultiByteToWideChar: 1343 ticks = 79% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 1
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 390 ticks, WideCharToMultiByte: 906 ticks = 132% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 500 ticks, MultiByteToWideChar: 843 ticks = 68% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 2
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 391 ticks, WideCharToMultiByte: 907 ticks = 131% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 500 ticks, MultiByteToWideChar: 843 ticks = 68% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 3
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 125 ticks, WideCharToMultiByte: 312 ticks = 149% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 172 ticks, MultiByteToWideChar: 281 ticks = 63% faster
Ready
Press any key to continue ...


As you can see, the performance increase for shorter strings is considerable.

Thank you for supporting this little adventure.  :thumbsup:

Biterider


LiaoMi

Large test:
-----------------------------------------------------------
Preparing the test...
RANGE = 0
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 375 ticks, WideCharToMultiByte: 422 ticks = 12% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 516 ticks, MultiByteToWideChar: 671 ticks = 30% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 1
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 1328 ticks, WideCharToMultiByte: 1844 ticks = 38% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 2094 ticks, MultiByteToWideChar: 2734 ticks = 30% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 2
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 672 ticks, WideCharToMultiByte: 859 ticks = 27% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 1047 ticks, MultiByteToWideChar: 1343 ticks = 28% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 3
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 859 ticks, WideCharToMultiByte: 1125 ticks = 30% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 1000 ticks, MultiByteToWideChar: 1391 ticks = 39% faster
Ready
Press any key to continue ...


Short test:
-----------------------------------------------------------
Preparing the test...
RANGE = 0
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 703 ticks, WideCharToMultiByte: 1203 ticks = 71% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 843 ticks, MultiByteToWideChar: 1515 ticks = 79% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 1
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 437 ticks, WideCharToMultiByte: 1031 ticks = 135% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 562 ticks, MultiByteToWideChar: 1234 ticks = 119% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 2
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 453 ticks, WideCharToMultiByte: 1047 ticks = 131% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 547 ticks, MultiByteToWideChar: 1218 ticks = 122% faster
Ready
-----------------------------------------------------------
Preparing the test...
RANGE = 3
Testing WideToUTF8...
SUCCEEDED       Fastest run     WideToUTF8: 140 ticks, WideCharToMultiByte: 375 ticks = 167% faster
Ready

Testing UTF8ToWide...
SUCCEEDED       Fastest run     UTF8ToWide: 187 ticks, MultiByteToWideChar: 375 ticks = 100% faster
Ready
Press any key to continue ...