AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

PosEx? Oder doch lieber Pos? - Performance!

Ein Thema von dGeek · begonnen am 22. Aug 2016 · letzter Beitrag vom 24. Aug 2016
 
Der schöne Günther

Registriert seit: 6. Mär 2013
6.199 Beiträge
 
Delphi 10 Seattle Enterprise
 
#5

AW: PosEx? Oder doch lieber Pos? - Performance!

  Alt 22. Aug 2016, 18:18
Also eine Millionen mal dauert Posex bei mir 6 Millisekunden und 7 Millisekunden für "Pos".

Delphi-Quellcode:
program Project11;

{$APPTYPE CONSOLE}

{$R *.res}

uses System.SysUtils, System.AnsiStrings, System.Diagnostics;

const
 s1 = 'Hallo Welt';
 s2 = 'lo';

 count = 1E6;

//{$Define Posex}

var
   times: Integer;
   result: Integer;
   stopWatch: TStopwatch;
begin
   times := 0;
   stopWatch := TStopwatch.StartNew();
   repeat
      {$If Defined(Posex)}
         result := System.AnsiStrings.PosEx(s2, s1);
      {$Else}
         result := System.Pos(s2, s1);
      {$EndIf}
      Inc(times);
   until (times = count);
   stopWatch.Stop();

   Writeln( stopWatch.ElapsedMilliseconds );
   readln;
end.

Wenn du in die Implementation schaust wirst du sehen dass PosEx nichts anderes tut als Pos aufzurufen. PosEx hat aber noch eine "inline"-Direktive. Ich kann kein Assembler lesen, könnte mir aber vorstellen dass der Compiler dann das komplette "Pos" inlined sodass er sich einen Sprung spart. Könnte das mal jemand prüfen?
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:18 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz