Note that there are some explanatory texts on larger screens.

plurals
  1. POconverting program to Multithreading, taking advantage of multicore cpu
    text
    copied!<p>i have a simple program with one procedure.</p> <pre><code>Procedure TForm1.btnKeywrdTransClick(Sender: TObject); Var i, ii : integer; ch_word, zword, uy_word: widestring; Begin TntListBox1.items.LoadFromFile('d:\new folder\chh.txt'); //Chinese TntListBox2.items.LoadFromFile('d:\new folder\uyy.txt'); //Uyword TntListBox4.items.LoadFromFile(Edit3.text); //list of poi files For I := 0 To TntListBox4.items.Count - 1 do Begin TntListBox3.items.LoadFromFile(TntListBox4.Items[i]); zword := tntlistbox3.Items.Text; //Poi For ii := 0 To TntListBox1.Items.count - 1 Do Begin loopz; ch_word := tntlistbox1.Items[ii]; uy_word := ' ' + TntListBox2.items[ii] + ' '; zword := wideFastReplace(zword, ch_word, uy_word, [rfReplaceAll]); //fastest, and better for large text End; TntListBox3.Items.text := zword; TntListBox3.items.SaveToFile(TntListBox4.Items[i]); end; end; </code></pre> <p>now my new computer has 4cores, is making this program multithreading will make it run faster (if i uses 4 thread, a thread per core) ? i have no experience with multithreading, i need your help thanks.</p> <p>ps : this is Loopz procedure </p> <pre><code>Procedure loopz; Var msg : tmsg; Begin While PeekMessage(Msg, 0, 0, 0, pm_Remove) Do Begin If Msg.Message = wm_Quit Then Halt(Msg.WParam); TranslateMessage(Msg); DispatchMessage(Msg); End; End; </code></pre> <p><strong>update 1 :</strong> from the answers, im gonna do</p> <p>1 - use a profiler to find the most time consuming code</p> <p>2 - try eliminate gui related things if possible</p> <p>3 - use threads.</p> <p>i'll report back . thanks all.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload