AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Delphi-PRAXiS - Lounge Delphi-News aus aller Welt How to accelerate 10 times the "For" loops with Delphi

How to accelerate 10 times the "For" loops with Delphi

Ein Thema von DP News-Robot · begonnen am 10. Jun 2019
Antwort Antwort
Benutzerbild von DP News-Robot
DP News-Robot

Registriert seit: 4. Jun 2010
14.954 Beiträge
 
#1

How to accelerate 10 times the "For" loops with Delphi

  Alt 10. Jun 2019, 10:00
To get the for loops to run up to 10 times faster you have to use PPI (Parallel programming Library) and if you don't believe it, run the following code: loop for As usual: uses System. Threading,//Parallel programming Library System. Diagnostics; TStopwatch// ... Procedure TForm1. btnForLoopRegularClick (sender: TObject); var SW: TStopwatch; I: integer; begin SW: = TStopwatch. StartNew; For I: = 0 to 99 do Sleep (10); Sw. Stop Label1. Text: = SW. ElapsedMilliseconds. ToString + ' MS '; end; Now the same loop using PPIprocedure TForm1. btnForLoopParallelClick (sender: TObject); var SW: TStopwatch; I: integer; begin SW: = TStopwatch. StartNew; TParallel. For (0, 99, procedure (I: integer) begin Sleep (10); End); Sw. Stop Label1. Text: = SW. ElapsedMilliseconds. ToString + ' MS '; end; In the first case the execution time is 1038 Msegs and in the second case of 117 Msegs., as you see the speed increase is in a range of 10 times approximately. I hope this Truc

Weiterlesen...
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

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 01:07 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz