<html>
<head>
</head>
<body class='hmmessage'><div dir='ltr'>


<div dir="ltr">

<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style>
<div dir="ltr">Hi Programmers,<br><br>according to Java Mission Control the current code in mkgmap <br>requires ~ 20% of the CPU time in Tags.keyPos(),<br>and a few more percent in other HashMaps related to tag keys.<br>A lot of this CPU time is required to compare the keys of tags <br>(which are String instances),&nbsp; which also causes quite a lot of data <br>being moved into CPU caches.<br><br>There are two ways to reduce this CPU time:<br>1) reduce the time required in Tags.keyPos()<br>This can be done if we use a dictionary to translate each <br>used tag key into a unique id (a short or int). Instead of storing and comparing<br>Strings we could then use the id, which in turn can be the index<br>to an array with the tag key.<br><br>2) reduce the number of calls of Element.getTag() which calls Tags.keyPos()<br>This can be done by some caching. Consider the following rules<br>barrier=* &amp; bicycle=*&nbsp;&nbsp;&nbsp; { set mkgmap:bicycle='${bicycle|subst:private=&gt;no}' }<br>barrier=* &amp; foot=*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { set mkgmap:foot='${foot|subst:private=&gt;no}' }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>barrier=* &amp; hgv=*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { set mkgmap:truck='${hgv|subst:private=&gt;no}' }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>barrier=* &amp; motorcar=*&nbsp;&nbsp; { set mkgmap:car='${motorcar|subst:private=&gt;no}' } <br><br>The result for the evaluation of tag barrier=* is a constant as none of the action blocks<br>changes it, but mkgmap really calls Element.getTag() again and again for each line.<br><br>In March 2012 I did some experiments with this idea and found a typical saving of 20%<br>run time with the default style, but I never finished it.<br><br>I think it is worth to start this again in a new branch, but it will involve a lot of small changes<br>to many sources, so I'd like to know if anybody else plans to code changes.<br><br>Gerd<br><br><br></div>
</div>
                                               </div></body>
</html>