[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-frameworks-devel
Subject:    Re: Review Request 129859: Add benchmark for KTextToHTML::convertToHtml
From:       Milian Wolff <mail () milianw ! de>
Date:       2017-01-23 19:03:30
Message-ID: 20170123190330.6406.50324 () mimi ! kde ! org
[Download RAW message or body]

--===============2634678937237044846==
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit


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

(Updated Jan. 23, 2017, 7:03 p.m.)


Status
------

This change has been marked as submitted.


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


--===============2634678937237044846==
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 8bit




<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="12" style="border: 1px #c9c399 \
solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">  \
<tr>  <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/129859/">https://git.reviewboard.kde.org/r/129859/</a>
  </td>
    </tr>
   </table>
   <br />



<table bgcolor="#e0e0e0" width="100%" cellpadding="12" style="border: 1px gray solid; \
border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">  <tr>
  <td>
   <h1 style="margin: 0; padding: 0; font-size: 10pt;">This change has been marked as \
submitted.</h1>  </td>
 </tr>
</table>
<br />


<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: \
1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; \
-webkit-border-radius: 6px;">  <tr>
  <td>

<div>Review request for KDE Frameworks, David Faure, Daniel Vrátil, and Laurent \
Montel.</div> <div>By Milian Wolff.</div>


<p style="color: grey;"><i>Updated Jan. 23, 2017, 7:03 p.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kcoreaddons
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">On my machine, the initial output is as follows for RelWithDebInfo:

PASS   : KTextToHTMLTest::benchHtmlConvert(plain)
RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;plain&quot;:
     4.0 msecs per iteration (total: 65, iterations: 16)
PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces)
RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;preserve-spaces&quot;:
     3.4 msecs per iteration (total: 55, iterations: 16)
PASS   : KTextToHTMLTest::benchHtmlConvert(highlight-text)
RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;highlight-text&quot;:
     4.2 msecs per iteration (total: 68, iterations: 16)
PASS   : KTextToHTMLTest::benchHtmlConvert(replace-smileys)
RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;replace-smileys&quot;:
     4.1 msecs per iteration (total: 66, iterations: 16)
PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces+highlight-text)
RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;preserve-spaces+highlight-text&quot;:
  3.6 msecs per iteration (total: 58, iterations: 16)
PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces+highlight-text+replace-smileys)
 RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;preserve-spaces+highlight-text+replace-smileys&quot;:
  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():&quot;plain&quot;:
     0.75 msecs per iteration (total: 96, iterations: 128)
PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces)
RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;preserve-spaces&quot;:
     0.71 msecs per iteration (total: 91, iterations: 128)
PASS   : KTextToHTMLTest::benchHtmlConvert(highlight-text)
RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;highlight-text&quot;:
     0.89 msecs per iteration (total: 57, iterations: 64)
PASS   : KTextToHTMLTest::benchHtmlConvert(replace-smileys)
RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;replace-smileys&quot;:
     0.75 msecs per iteration (total: 96, iterations: 128)
PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces+highlight-text)
RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;preserve-spaces+highlight-text&quot;:
  0.79 msecs per iteration (total: 51, iterations: 64)
PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces+highlight-text+replace-smileys)
 RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;preserve-spaces+highlight-text+replace-smileys&quot;:
  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&#39;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():&quot;plain&quot;:
     0.40 msecs per iteration (total: 52, iterations: 128)
PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces)
RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;preserve-spaces&quot;:
     0.36 msecs per iteration (total: 93, iterations: 256)
PASS   : KTextToHTMLTest::benchHtmlConvert(highlight-text)
RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;highlight-text&quot;:
     0.51 msecs per iteration (total: 66, iterations: 128)
PASS   : KTextToHTMLTest::benchHtmlConvert(replace-smileys)
RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;replace-smileys&quot;:
     0.41 msecs per iteration (total: 53, iterations: 128)
PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces+highlight-text)
RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;preserve-spaces+highlight-text&quot;:
  0.44 msecs per iteration (total: 57, iterations: 128)
PASS   : KTextToHTMLTest::benchHtmlConvert(preserve-spaces+highlight-text+replace-smileys)
 RESULT : KTextToHTMLTest::benchHtmlConvert():&quot;preserve-spaces+highlight-text+replace-smileys&quot;:
  0.46 msecs per iteration (total: 59, iterations: 128)

Mark some methods as const</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: \
inherit;white-space: inherit;">the test still passes fine. note that the above is \
actually split into 4 commits locally</p></pre>  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>autotests/ktexttohtmltest.h <span style="color: \
grey">(3aaa5810d84ecb05b68b8a20b94bd281cfe3a6ba)</span></li>

 <li>autotests/ktexttohtmltest.cpp <span style="color: \
grey">(fa8bbf261acd7b77ac502f14ca7820d3aeed7b55)</span></li>

 <li>src/lib/text/ktexttohtml.cpp <span style="color: \
grey">(9b15cb27c7b9998971e2efbc198c3f840bf34959)</span></li>

 <li>src/lib/text/ktexttohtml_p.h <span style="color: \
grey">(5e343485b26eb03ce2805f3a9f178a395f9b46a3)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/129859/diff/" style="margin-left: \
3em;">View Diff</a></p>






  </td>
 </tr>
</table>



  </div>
 </body>
</html>


--===============2634678937237044846==--


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic