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...