Review Request 129859: Add benchmark for KTextToHTML::convertToHtml

David Faure faure at kde.org
Fri Jan 20 21:21:20 UTC 2017


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/129859/#review102118
-----------------------------------------------------------


Ship it!




Ship It!

- David Faure


On Jan. 20, 2017, 8:21 p.m., Milian Wolff wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/129859/
> -----------------------------------------------------------
> 
> (Updated Jan. 20, 2017, 8:21 p.m.)
> 
> 
> Review request for KDE Frameworks, David Faure, Daniel Vrátil, and Laurent Montel.
> 
> 
> Repository: kcoreaddons
> 
> 
> Description
> -------
> 
> On my machine, the initial output is as follows for RelWithDebInfo:
> 
> PASS   : KTextToHTMLTest::benchHtmlConvert(plain)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"plain":
>      4.0 msecs per iteration (total: 65, iterations: 16)
> PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"preserve-spaces":
>      3.4 msecs per iteration (total: 55, iterations: 16)
> PASS   : KTextToHTMLTest::benchHtmlConvert(highlight-text)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"highlight-text":
>      4.2 msecs per iteration (total: 68, iterations: 16)
> PASS   : KTextToHTMLTest::benchHtmlConvert(replace-smileys)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"replace-smileys":
>      4.1 msecs per iteration (total: 66, iterations: 16)
> PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces+highlight-text)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"preserve-spaces+highlight-text":
>      3.6 msecs per iteration (total: 58, iterations: 16)
> PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces+highlight-text+replace-smileys)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"preserve-spaces+highlight-text+replace-smileys":
>      3.5 msecs per iteration (total: 57, iterations: 16)
> 
> Replace heap-allocated list of chars with QStringLiteral
> 
> The main bottleneck in the benchmark for KTextToHTML was actually
> constructing the temporary list of word-boundaries. Instead of
> doing that all the time, use a QStringLiteral-constructed static
> QString.
> 
> This improves the benchmarks by more than ~4x on my machine,
> all compiled in RelWithDebInfo:
> 
> PASS   : KTextToHTMLTest::benchHtmlConvert(plain)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"plain":
>      0.75 msecs per iteration (total: 96, iterations: 128)
> PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"preserve-spaces":
>      0.71 msecs per iteration (total: 91, iterations: 128)
> PASS   : KTextToHTMLTest::benchHtmlConvert(highlight-text)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"highlight-text":
>      0.89 msecs per iteration (total: 57, iterations: 64)
> PASS   : KTextToHTMLTest::benchHtmlConvert(replace-smileys)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"replace-smileys":
>      0.75 msecs per iteration (total: 96, iterations: 128)
> PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces+highlight-text)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"preserve-spaces+highlight-text":
>      0.79 msecs per iteration (total: 51, iterations: 64)
> PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces+highlight-text+replace-smileys)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"preserve-spaces+highlight-text+replace-smileys":
>      0.79 msecs per iteration (total: 51, iterations: 64)
> 
> Remove temporary string allocations
> 
> Instead of calling .mid() to compare to a QLatin1String,
> call .midRef() as that won't allocate.
> 
> Improves the performance of the unit test by ~2x on my
> machine when compiling in RelWithDebInfo:
> 
> PASS   : KTextToHTMLTest::benchHtmlConvert(plain)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"plain":
>      0.40 msecs per iteration (total: 52, iterations: 128)
> PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"preserve-spaces":
>      0.36 msecs per iteration (total: 93, iterations: 256)
> PASS   : KTextToHTMLTest::benchHtmlConvert(highlight-text)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"highlight-text":
>      0.51 msecs per iteration (total: 66, iterations: 128)
> PASS   : KTextToHTMLTest::benchHtmlConvert(replace-smileys)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"replace-smileys":
>      0.41 msecs per iteration (total: 53, iterations: 128)
> PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces+highlight-text)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"preserve-spaces+highlight-text":
>      0.44 msecs per iteration (total: 57, iterations: 128)
> PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces+highlight-text+replace-smileys)
> RESULT : KTextToHTMLTest::benchHtmlConvert():"preserve-spaces+highlight-text+replace-smileys":
>      0.46 msecs per iteration (total: 59, iterations: 128)
> 
> Mark some methods as const
> 
> 
> Diffs
> -----
> 
>   autotests/ktexttohtmltest.h 3aaa5810d84ecb05b68b8a20b94bd281cfe3a6ba 
>   autotests/ktexttohtmltest.cpp fa8bbf261acd7b77ac502f14ca7820d3aeed7b55 
>   src/lib/text/ktexttohtml.cpp 9b15cb27c7b9998971e2efbc198c3f840bf34959 
>   src/lib/text/ktexttohtml_p.h 5e343485b26eb03ce2805f3a9f178a395f9b46a3 
> 
> Diff: https://git.reviewboard.kde.org/r/129859/diff/
> 
> 
> Testing
> -------
> 
> the test still passes fine. note that the above is actually split into 4 commits locally
> 
> 
> Thanks,
> 
> Milian Wolff
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20170120/6b6b46ac/attachment.html>


More information about the Kde-frameworks-devel mailing list