[fpc-devel] performance tests: reference counted vs non-reference counted

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Nov 16 20:34:01 CET 2007


On Fri, 16 Nov 2007 14:27:50 +0200
"Graeme Geldenhuys" <graemeg.lists at gmail.com> wrote:

> On 16/11/2007, Luiz Americo Pereira Camara <pascalive at bol.com.br>
> wrote:
> >
> > A single program like the below leaks memory. To the  object be
> > freed automatically is necessary to declare Obj as IUnknown.
> > I wonder if your test is leaking memory.
> 
> That was an oversight, thanks!  Point taken, I was using interfaced
> objects incorrectly.
> 
> Yet in the last few test modifications, I explicitly free both
> Reference Counted and non-Reference Counted objects, so that shouldn't
> cause memory leaks.
> 
> 
> With all these tests, we have cleared up a few issues.  One still
> outstanding is why TInterfacedObject performs better that TObject
> using FPC?

Either you have still some measurement problems, or see Jonas hint
about wrong alignment.

Attached is the current test. 
Make sure you run the program one or two times before, so that the OS
caching does not interfere:

$ ./performancetest 
...OS caching polluted...
$ ./performancetest 
...OS caching polluted...
$ ./performancetest 
10000000 iterations in 1169 ms (no reference counting)
10000000 iterations in 815 ms (no reference counting)
10000000 iterations in 1005 ms (reference counting)
10000000 iterations in 1002 ms (reference counting)
10000000 iterations in 1160 ms (no reference counting with MyBaseObject)
10000000 iterations in 1154 ms (no reference counting with MyBaseObject)
10000000 iterations in 1404 ms (reference counting with MyBaseObject)
10000000 iterations in 1344 ms (reference counting with MyBaseObject)
$ ./performancetest 
10000000 iterations in 808 ms (no reference counting)
10000000 iterations in 803 ms (no reference counting)
10000000 iterations in 992 ms (reference counting)
10000000 iterations in 990 ms (reference counting)
10000000 iterations in 1294 ms (no reference counting with MyBaseObject)
10000000 iterations in 1172 ms (no reference counting with MyBaseObject)
10000000 iterations in 1447 ms (reference counting with MyBaseObject)
10000000 iterations in 1369 ms (reference counting with MyBaseObject)

Notes:
As you can see I had to run each 10 million times because FPC is so
fast, even without optimizations and there is still an error of 0.1 ms
from the various processes running on todays linux. 
Compiler flags: -S2cgi -OG1 -gl
Make also sure, that you have at least 500mb of free RAM. Otherwise you
measure your disk speed.


Mattias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: performancetest.lpr
Type: text/lazarus-project-source
Size: 5359 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20071116/ddbe3672/attachment.bin>


More information about the fpc-devel mailing list