[Lazarus] Default uses clause in project unit
Mattias Gaertner
nc-gaertnma at netcologne.de
Thu Aug 27 11:36:41 CEST 2009
On Thu, 27 Aug 2009 09:08:18 +0200
Graeme Geldenhuys <graemeg at opensoft.homeip.net> wrote:
> Mattias Gärtner wrote:
>[...]
> > So adding cthreads will deccelerate your application, even if you do
> > not start any thread.
>
> Is this in theory, or has somebody actually done some speed tests to
> see by what factor the applications are slowed down? What would be a
> good test to see a speed difference?
For example:
program bench1;
{$mode objfpc}{$H+}
uses
//cthreads,
//cmem,
classes, sysutils;
var
s1: String;
s2: String;
i: Integer;
s: String;
t: TThread;
begin
//t:=TThread.Create(true);
s1:=IntToStr(Paramcount+12345);
s2:=IntToStr(Paramcount+23456);
for i:=1 to 500000000 do begin
s:=s1;
s:=s2;
end;
end.
Under OS X the above program takes on my mac book about 15 seconds.
Uncomment the cthreads unit: 21 seconds
Uncomment the t:=TThread line: 53 seconds.
fpc 2.2.4
Under my Linux machine the: above program takes about 7.5 seconds.
Uncomment the cthreads unit: 7.5 seconds
Uncomment the t:=TThread line: 20 seconds.
fpc 2.2.5 (afair 2.2.4 behaves similar)
In the above example the loop does not allocate memory so the cmem unit
makes no difference. Normally it is recommended - at least under OS X.
> > See also
> > http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial#Units_needed_for_a_multi-threaded_application
>
> Thanks for the link, but that wiki pages misses a vital piece of
> information - and the reason for this message thread. It should
> include the answer as to why Windows has multi-threading support
> enabled by default, but all other platforms do not. It just says that
> other non-Windows platforms are handled differently, but it doesn't
> say why.
Please find out and add the answer.
>[...the same text in other words...]
Maybe this thread should be moved to the fpc list?
Mattias
More information about the Lazarus
mailing list