title: Parallel processing strings Delphi full available CPU usage
body: <p>The goal is to achieve full usage of the available cores, in converting floats to strings in a single Delphi application. I think this problem applies to the general processing of string. Yet in my example I am specifically using the FloatToStr method.</p>
  
  <p>What I am doing (I've kept this very simple so there is little ambiguity around the implementation):</p>
  
  <ul>
  <li>Using Delphi XE6</li>
  <li>Create thread objects which inherit from TThread, and start them.</li>
  <li>In the thread execute procedure it will convert a large amount of
  doubles into strings via the FloatToStr method. </li>
  <li>To simplify, these doubles are just the same constant, so there is no
  shared or global memory resource required by the threads.</li>
  </ul>
  
  <p>Although multiple cores are used, the CPU usage % always will max out on the amount of a single core. I understand this is an established issue. So I have some specific questions.</p>
  
  <p>In a simple way the same operation could be done by multiple app instances, and thereby achieve more full usage of the available CPU. Is it possible to do this effectively within the same executable ?
  I.e. assign threads different process ids on the OS level or some equivalent division recognised by the OS ? Or is this simply not possible in out of the box Delphi ?</p>
  
  <p>On scope :
  I know there are different memory managers available &amp; other groups have tried changing some of the lower level asm lock usage <a href="http://synopse.info/forum/viewtopic.php?id=57">http://synopse.info/forum/viewtopic.php?id=57</a>
  But, I am asking this question in the scope of not doing things at such a low level.</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p>Hi J. My code is deliberately very simple :</p>
  
  <pre><code>TTaskThread = class(TThread)
  public
    procedure Execute; override;
  end;
  
  procedure TTaskThread.Execute;
  var
    i: integer;
  begin
    Self.FreeOnTerminate := True;
    for i := 0 to 1000000000 do
      FloatToStr(i*1.31234);
  end;
  
  procedure TfrmMain.Button1Click(Sender: TObject);
  var
    t1, t2, t3: TTaskThread;
  begin
    t1 := TTaskThread.Create(True);
    t2 := TTaskThread.Create(True);
    t3 := TTaskThread.Create(True);
    t1.Start;
    t2.Start;
    t3.Start;
  end;
  </code></pre>
  
  <p>This is a 'test code', where the CPU (via performance monitor) maxes out at 25% (I have 4 cores). If the FloatToStr line is swapped for a non string operation, e.g. Power(i, 2), then the performance monitor shows the expected 75% usage.
  (Yes there are better ways to measure this, but I think this is sufficient for the scope of this question)</p>
  
  <p>I have explored this issue fairly thoroughly. The purpose of the question was to put forth the crux of the issue in a very simple form.</p>
  
  <p>I am asking about limitations when using the FloatToStr method. And asking is there an implementation incarnation which will permit better usage of available cores.</p>
  
  <p>Thanks.</p>