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

Graeme Geldenhuys graemeg.lists at gmail.com
Fri Nov 16 11:50:00 CET 2007


Hi,

We have implemented a BaseObject class in the tiOPF project that can
be reference counted or not. Based on the constructor used. What was
really strange was when we started doing tests to see how it would
affect our performance. Some of us using tiOPF have applications that
creates 10's of 1000's of objects, so it does make a difference.

I've put together a console test application generating the results
show below (the application creates as many objects as it can in 5
seconds). It also shows our interface implementation compared to
TInterfacedObject.  See attached files. One is the FPC program (*.lpr)
and one is the Delphi 7 program (*.dpr) source.

Here is the strange behaviour we detected.  Anybody got answers for these?

*  The first two tests have opposite results under FPC vs Delphi. Why??

*  What is so different in our interfaced class implementation that
   degrades performance that much!!??

*  Why is our non-reference counted implementation faster than TObject
    under FPC?  We even changed the order of tests to see if that makes
   a difference, but it didn't. See test result 3.


Speed test results....


***** FPC 2.2.0 under Linux (Ubuntu 7.10)
graemeg at graemeg:Demo$ ./performancetest
2029 iterations in 5 seconds (no reference counting)
3185 iterations in 5 seconds (reference counting)
2469 iterations in 5 seconds (no reference counting with MyBaseObject)
935 iterations in 5 seconds (reference counting with MyBaseObject)


***** Delphi 7 under Windows 2000
C:\programming\tests\performancetest>performancetest
2721 iterations in 5 seconds (no reference counting)
1309 iterations in 5 seconds (reference counting)
2255 iterations in 5 seconds (no reference counting with MyBaseObject)
652 iterations in 5 seconds (reference counting with MyBaseObject)


We even changed the order of tests to see if that makes a difference...


***** FPC 2.2.0 under Linux (Ubuntu 7.10)
graemeg at graemeg:Demo_TtiBaseObject$ ./performancetest
2048 iterations in 5 seconds (no reference counting with MyBaseObject)
1874 iterations in 5 seconds (no reference counting)
2877 iterations in 5 seconds (reference counting)
566 iterations in 5 seconds (reference counting with MyBaseObject)


Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: performancetest.dpr
Type: application/octet-stream
Size: 4087 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20071116/83371193/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: performancetest.lpr
Type: application/octet-stream
Size: 5596 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20071116/83371193/attachment-0001.obj>


More information about the fpc-devel mailing list