[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: Re: Review Request 108992: Simple optimizations in SignalPlotter
From: "Aaron J. Seigo" <aseigo () kde ! org>
Date: 2013-02-26 12:50:20
Message-ID: 20130226125020.27505.85710 () vidsolbach ! de
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
> On Feb. 22, 2013, 1:32 a.m., Aaron J. Seigo wrote:
> > plasma/widgets/signalplotter.cpp, line 230
> > <http://git.reviewboard.kde.org/r/108992/diff/1/?file=114209#file114209line230>
> >
> > no point in taking PODs out of the loop
>
> Raul Fernandes wrote:
> Actually, the benefit exists in PODs too (the compiler has to adjust the \
> stack each iteration) but is minor. I agree. I don't agree that it \
> uglifies the code or make it less readable. To me, it doesn't make any \
> difference to readability and has the (little) gain in performance. My \
> opinion.
So we have a difference in opinion when it comes to readability, and that's \
what it is: an opinion. As the maintainer, my opinion wins in a tie :) My \
reason for this is that we end up with more variables outside the scope \
they are used which means to understand the loop one needs to read more \
outside the loop, and should other variables of similar name appear later \
on .....
PODs have very, very little overhead and we value the readability over such \
micro-optimizations. to confirm this with actual numbers i wrote a small \
test program that interates 10 million times performing simple math on 6 \
ints that are declared in the loop or out of it. result? neither exceeded \
1ms. so in this case, it is not worth it.
Conclusion: PODs will remain in the loops. Thanks :)
- Aaron J.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/108992/#review27877
-----------------------------------------------------------
On Feb. 22, 2013, 7:17 p.m., Raul Fernandes wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/108992/
> -----------------------------------------------------------
>
> (Updated Feb. 22, 2013, 7:17 p.m.)
>
>
> Review request for Plasma.
>
>
> Description
> -------
>
> - create variables and classes outside the loops
> - reserve space in QList if we know already how many items will be added \
> (avoid unnecessary reallocations)
> - use const_iterator when possible
> - remove a useless call (p->setPen(Qt::NoPen) - it will be set latter \
> before be used)
> - avoid multiplications (x3, x2, x1 and x0)
>
>
> Diffs
> -----
>
> plasma/widgets/signalplotter.cpp 8e9e294
>
> Diff: http://git.reviewboard.kde.org/r/108992/diff/
>
>
> Testing
> -------
>
> I have tested with KDE 4.10 with no problems.
> I have seen a improvement of about 5% in drawPlots() function, the most \
> expensive function in painting.
>
> Thanks,
>
> Raul Fernandes
>
>
[Attachment #5 (text/html)]
<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px \
#c9c399 solid;"> <tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="http://git.reviewboard.kde.org/r/108992/">http://git.reviewboard.kde.org/r/108992/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; \
padding-left: 10px;"> <p style="margin-top: 0;">On February 22nd, 2013, \
1:32 a.m. UTC, <b>Aaron J. Seigo</b> wrote:</p> <blockquote \
style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid \
#C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;"> <thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid \
#C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;"> <a \
href="http://git.reviewboard.kde.org/r/108992/diff/1/?file=114209#file114209line230" \
style="color: black; font-weight: bold; text-decoration: \
underline;">plasma/widgets/signalplotter.cpp</a> <span style="font-weight: \
normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: \
center;"> <tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: \
0; ">void SignalPlotter::reorderPlots(const QList<uint>& \
newOrder)</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; \
"></pre></td> <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; \
border-right: 1px solid #C0C0C0;" align="right"><font \
size="2">230</font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="kt">int</span> <span class="n">newIndex</span><span \
class="p">;</span></pre></td> </tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">no point in taking PODs out of the loop</pre> </blockquote>
<p>On February 22nd, 2013, 7:15 p.m. UTC, <b>Raul Fernandes</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; \
padding-left: 10px;"> <pre style="white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">Actually, the benefit exists in PODs too (the compiler has to \
adjust the stack each iteration) but is minor. I agree. I don't agree \
that it uglifies the code or make it less readable. To me, it doesn't \
make any difference to readability and has the (little) gain in \
performance. My opinion. </pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">So we have a difference in opinion when it comes to \
readability, and that's what it is: an opinion. As the maintainer, my \
opinion wins in a tie :) My reason for this is that we end up with more \
variables outside the scope they are used which means to understand the \
loop one needs to read more outside the loop, and should other variables of \
similar name appear later on .....
PODs have very, very little overhead and we value the readability over such \
micro-optimizations. to confirm this with actual numbers i wrote a small \
test program that interates 10 million times performing simple math on 6 \
ints that are declared in the loop or out of it. result? neither exceeded \
1ms. so in this case, it is not worth it.
Conclusion: PODs will remain in the loops. Thanks :)</pre>
<br />
<p>- Aaron J.</p>
<br />
<p>On February 22nd, 2013, 7:17 p.m. UTC, Raul Fernandes wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('http://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px \
black solid;"> <tr>
<td>
<div>Review request for Plasma.</div>
<div>By Raul Fernandes.</div>
<p style="color: grey;"><i>Updated Feb. 22, 2013, 7:17 p.m.</i></p>
<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;">- create variables and classes outside the \
loops
- reserve space in QList if we know already how many items will be added \
(avoid unnecessary reallocations)
- use const_iterator when possible
- remove a useless call (p->setPen(Qt::NoPen) - it will be set latter \
before be used)
- avoid multiplications (x3, x2, x1 and x0)</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;">I have tested with KDE 4.10 with no problems. I have seen a \
improvement of about 5% in drawPlots() function, the most expensive \
function in painting.</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>plasma/widgets/signalplotter.cpp <span style="color: \
grey">(8e9e294)</span></li>
</ul>
<p><a href="http://git.reviewboard.kde.org/r/108992/diff/" \
style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic