<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>So someone reached out to me directly again asking for an FPC
      optimisation.  Now I want to see if this is possible to optimise
      and won't break something or be annoying specific.<br>
    </p>
    <div class="moz-forward-container">Gareth aka. Kit<br>
      <br>
      -------- Forwarded Message --------
      <table class="moz-email-headers-table" cellspacing="0"
        cellpadding="0" border="0">
        <tbody>
          <tr>
            <th valign="BASELINE" nowrap="nowrap" align="RIGHT">Subject:
            </th>
            <td>Re: An optimization suggestion for FPC</td>
          </tr>
          <tr>
            <th valign="BASELINE" nowrap="nowrap" align="RIGHT">Date: </th>
            <td>Sun, 28 Jun 2020 11:30:09 +0100</td>
          </tr>
          <tr>
            <th valign="BASELINE" nowrap="nowrap" align="RIGHT">From: </th>
            <td>J. Gareth Moreton <a class="moz-txt-link-rfc2396E" href="mailto:gareth@moreton-family.com"><gareth@moreton-family.com></a></td>
          </tr>
          <tr>
            <th valign="BASELINE" nowrap="nowrap" align="RIGHT">To: </th>
            <td>Okoba <a class="moz-txt-link-rfc2396E" href="mailto:okobapatino@protonmail.com"><okobapatino@protonmail.com></a></td>
          </tr>
        </tbody>
      </table>
      <br>
      <br>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <p>Heh, I'm honoured you came to me directly.  I'll see if I can
        work anything out.  A lot of it is down to where the record is
        stored.  If it's on the stack, an optimisation shouldn't be
        difficult, but if it's on the heap somewhere, then it will be a
        bit more difficult.  Do you have your C++ example, and which C++
        compiler did you use?</p>
      <p>Gareth aka. Kit<br>
      </p>
      <div class="moz-cite-prefix">On 28/06/2020 11:06, Okoba wrote:<br>
      </div>
      <blockquote type="cite"
cite="mid:COSy75N1mtTY5M6vQwnzsgyu8OVBhd4k8garrPmksb_OhkIGbM6JKRQ1v9t7k4V46EyqUvoEmLOhGRQ8g_tc-9M4GIUn5sdyS8bmpm6p14k=@protonmail.com">
        <meta http-equiv="content-type" content="text/html;
          charset=UTF-8">
        <div>Hi,<br>
        </div>
        <div>It seems you are interested in optimizing FPC and I have a
          trouble with it and wanted to check it with you if I may.<br>
        </div>
        <div>I like to have a way to pass the record variable and inc it
          without losing speed. I wrote a sample and ran it with FPC
          trunk in Win64 and the times are commented. I should say the
          times for Delphi for the same target is the same. And tried a
          C++ version and all the times are almost the same and near
          250.<br>
        </div>
        <div>I tried many ways including absolute, pointer, custom asm
          functions, custom functions with const and var params and the
          are almost always slower than the first loop.<br>
        </div>
        <div>So is there anyway to have a custom Inc function that get
          he record variable and inc it without losing speed in compare
          to the system inc?<br>
        </div>
        <div><br>
        </div>
        <div>Regards.</div>
        <div><br>
        </div>
        <div class="protonmail_signature_block
          protonmail_signature_block-empty">
          <div class="protonmail_signature_block-user
            protonmail_signature_block-empty"><br>
          </div>
          <div class="protonmail_signature_block-proton
            protonmail_signature_block-empty"><br>
          </div>
        </div>
        <div>program Project1;<br>
        </div>
        <div><br>
        </div>
        <div>uses<br>
        </div>
        <div>  SysUtils;<br>
        </div>
        <div><br>
        </div>
        <div>type<br>
        </div>
        <div>  TTest = record<br>
        </div>
        <div>    P: int64;<br>
        </div>
        <div>  end;<br>
        </div>
        <div><br>
        </div>
        <div>  procedure Test;<br>
        </div>
        <div>  var<br>
        </div>
        <div>    V: TTest;<br>
        </div>
        <div>    P: int64;<br>
        </div>
        <div>    T: UInt64;<br>
        </div>
        <div>    i, C: integer;<br>
        </div>
        <div>  begin<br>
        </div>
        <div>    C := 1000 * 1000 * 1000;<br>
        </div>
        <div><br>
        </div>
        <div>    T := GetTickCount64;<br>
        </div>
        <div>    P := 1;<br>
        </div>
        <div>    for i := 1 to C do<br>
        </div>
        <div>      Inc(P);<br>
        </div>
        <div>    WriteLn(GetTickCount64 - T); //266<br>
        </div>
        <div><br>
        </div>
        <div>    T := GetTickCount64;<br>
        </div>
        <div>    V.P := 1;<br>
        </div>
        <div>    for i := 1 to C do<br>
        </div>
        <div>      Inc(V.P);<br>
        </div>
        <div>    WriteLn(GetTickCount64 - T); //1400<br>
        </div>
        <div><br>
        </div>
        <div>    T := GetTickCount64;<br>
        </div>
        <div>    V.P := 1;<br>
        </div>
        <div>    P := V.P;<br>
        </div>
        <div>    for i := 1 to C do<br>
        </div>
        <div>      Inc(P);<br>
        </div>
        <div>    P := V.P;<br>
        </div>
        <div>    WriteLn(GetTickCount64 - T);  //250<br>
        </div>
        <div>  end;<br>
        </div>
        <div><br>
        </div>
        <div>begin<br>
        </div>
        <div>  Test;<br>
        </div>
        <div>  ReadLn;<br>
        </div>
        <div>end.<br>
        </div>
        <div><br>
        </div>
      </blockquote>
    </div>
  <div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br />
<table style="border-top: 1px solid #D3D4DE;">
        <tr>
        <td style="width: 55px; padding-top: 13px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;" /></a></td>
                <td style="width: 470px; padding-top: 12px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a>
                </td>
        </tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>