AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Delphi Procedure vs Function, Vor- und Nachteile
Thema durchsuchen
Ansicht
Themen-Optionen

Procedure vs Function, Vor- und Nachteile

Ein Thema von KodeZwerg · begonnen am 15. Apr 2018 · letzter Beitrag vom 23. Apr 2018
 
Benutzerbild von KodeZwerg
KodeZwerg

Registriert seit: 1. Feb 2018
3.691 Beiträge
 
Delphi 11 Alexandria
 
#24

AW: Procedure vs Function, Vor- und Nachteile

  Alt 22. Apr 2018, 07:41
Kleiner Bench Verbesserungs-Vorschlag
Delphi-Quellcode:
const
  amount = 1000000;
  attempts = 50;
var
  x,y: cardinal;
// tickstart, tickfinish: cardinal;
  ticks: cardinal; // eine variable genügt
// allcounts: cardinal;
  s: String;
begin
  Randomize; // einmal reicht, oder?
  SetLength(s, Random(255)); // lieber nur ein random um ein ein präziseres ergebniss zu erhalten, man will ja nicht random benchen
// allcounts := 0;
  for x := 1 to attempts do
  begin
    y := 1;
    ticks := GetTickCount;
// tickstart := GetTickCount;
    while y <= amount do
    begin
// Randomize;
// SetLength(s, Random(255));
      //entw Foo(s);
      //oder FooC(s);
      //oder FooV(s);
      inc(y);
    end;
// tickfinish := GetTickCount;
// allcounts := allcounts + tickfinish - tickstart; // 0 + tickdifferenz
    ticks := GetTickCount - ticks;
  end;
// showmessage(inttostr((allcounts div attempts)));
  showmessage(inttostr((ticks div attempts)));
end;
Ich habe es noch nicht getestet aber so erscheint es mir logischer
Gruß vom KodeZwerg
  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 15:57 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