Found a performance bug

David Thielen <[email protected]> Thu, 31 May 2018 22:23:46 +0000
Newsgroups gmane.comp.java.ikvm.devel
Message-ID <SN1PR12MB043005D5A5E9FA7E66E8164AC1630@SN1PR12MB0430.namprd12.prod.outlook.com>
--===============0960995442299031692==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_SN1PR12MB043005D5A5E9FA7E66E8164AC1630SN1PR12MB0430namp_"

--_000_SN1PR12MB043005D5A5E9FA7E66E8164AC1630SN1PR12MB0430namp_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi all;

We'll be creating a branch of IKVM (tentative name Windward MVKI) and we'll=
 put it up on NuGet. I'll email it here when we have it.

The issue we found is in converter.cs - C2J.ConvertShape(). It accesses pat=
h.PathPoints[i]. The problem is on each call to that it creates the array o=
f points. Moving the call to PathPoints outside the for loop and then acces=
sing the copy of the array built once to access speeds it up - a lot.

In other words:

for (int i =3D 0; i < points.Length; i++) {
PointF point =3D path.PathPoints[i];

Is changed to:

PointF[] points =3D path.PathPoints;
for (int i =3D 0; i < points.Length; i++) {
PointF point =3D points[i];

Thanks - dave


--_000_SN1PR12MB043005D5A5E9FA7E66E8164AC1630SN1PR12MB0430namp_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Hi all;<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">We&#8217;ll be creating a branch of IKVM (tentative =
name Windward MVKI) and we&#8217;ll put it up on NuGet. I&#8217;ll email it=
 here when we have it.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">The issue we found is in converter.cs &#8211; C2J.Co=
nvertShape(). It accesses path.PathPoints[i]. The problem is on each call t=
o that it creates the array of points. Moving the call to PathPoints outsid=
e the for loop and then accessing the copy
 of the array built once to access speeds it up &#8211; a lot.<o:p></o:p></=
p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">In other words:<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;color:blue">for</span><span style=3D"font-siz=
e:9.5pt;font-family:Consolas;color:black"> (</span><span style=3D"font-size=
:9.5pt;font-family:Consolas;color:blue">int</span><span style=3D"font-size:=
9.5pt;font-family:Consolas;color:black">
 i =3D 0; i &lt; points.Length; i&#43;&#43;) {<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-size:=
9.5pt;font-family:Consolas;color:#2B91AF">PointF</span><span style=3D"font-=
size:9.5pt;font-family:Consolas;color:black"> point =3D path.PathPoints[i];=
</span><o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Is changed to:<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;color:#2B91AF">PointF</span><span style=3D"fo=
nt-size:9.5pt;font-family:Consolas;color:black">[] points =3D path.PathPoin=
ts;<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;color:blue">for</span><span style=3D"font-siz=
e:9.5pt;font-family:Consolas;color:black"> (</span><span style=3D"font-size=
:9.5pt;font-family:Consolas;color:blue">int</span><span style=3D"font-size:=
9.5pt;font-family:Consolas;color:black">
 i =3D 0; i &lt; points.Length; i&#43;&#43;) {<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-size:=
9.5pt;font-family:Consolas;color:#2B91AF">PointF</span><span style=3D"font-=
size:9.5pt;font-family:Consolas;color:black"> point =3D points[i];</span><o=
:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Thanks &#8211; dave<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

--_000_SN1PR12MB043005D5A5E9FA7E66E8164AC1630SN1PR12MB0430namp_--


--===============0960995442299031692==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--===============0960995442299031692==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Ikvm-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ikvm-developers

--===============0960995442299031692==--