CP vs C++

From: Fyodor Tkachov <"Fyodor>
Date: Wed, 28 Jan 2004 15:58:23 +0100

----boundary-LibPST-iamunique-601988546_-_-
Content-type: text/plain

Hi All!

I'd like to share an interesting experience -- someone asked a while ago about the cost of array boundary checks etc.

A pretty complex algorithm was developed in Component Pascal for the needs of physics at CERN (the so-called optimal jet finder). The algorithmic experimentation required was significant, and I cannot imagine how it could have been done within the time it took in Blackbox (4 focused weeks) with any other language.

The program is not very large, consists of 4 modules and contains a nice mix of normal numerical stuff (arrays, sin's etc.), bit manipulation, records, pointers and lists (the data structures remain static once initialized -- this was possible and needed for the port), true object stuff (so that "dynamic dispatch" had to be used in the C++ version).
So it's quite representative -- on top of being fully real-life.

Now, since CERN physicists use all possible kinds of hardware, the algorithm was ported to Fortran 77 and recently to C++.

The C++ version is a straightforward copy of the CP version.
The tests were run on Win XP, and MS Visual C++ compiler was used.

The C++ variant compiled as a "Debug" version was 3 times slower than CP -- 9.x : 3.6 (sec).
The C++ variant compiled as "Release" with full optimization clocked in at 3.5 sec.
The time measurement fluctuations in all cases was 0.1.

The compilation time in the last case was noticeable -- must be >10 times more than for CP where it is barely noticeable.

A CERN C++ guru insists that the resulting C++ code is not good, too many friends and typedefs, etc. -- I am not sure as the CP version is neat and nice, and the earlier Fortran version produced from the same CP original is said to be very good by the same guru.

So, make your conclusions.
I have no numbers for Fortran yet.

Cheers
-------------------------
Fyodor Tkachov

Powered by the E-mail PIM - Info Select - www.miclog.com
--------------------------------------------

To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
   blackbox-request{([at]})nowhere.xy

To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.

Send any problem reports or questions related to this email list to the list owner at
   owner-blackbox{([at]})nowhere.xy

Current posting policy:

a) To post you should use the same address by which you are subscribed to the mailing list. That way, the list server will recognize you as subscriber and forward your posting immediately, without creating any overhead.

b) If, for some reason, you cannot post from the address, by which you are subscribed, your message will be moderated to avoid spam. Please understand that moderation will often cause some delay, in particular over weekends or holydays.



----boundary-LibPST-iamunique-601988546_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIEhpIEFsbCFccGFyDQpccGFyDQpJJ2QgbGlrZSB0
byBzaGFyZSBhbiBpbnRlcmVzdGluZyBleHBlcmllbmNlIC0tIHNvbWVvbmUgYXNrZWQgYSB3aGls
ZSBhZ28gYWJvdXQgdGhlIGNvc3Qgb2YgYXJyYXkgYm91bmRhcnkgY2hlY2tzIGV0Yy5ccGFyDQpc
cGFyDQpBIHByZXR0eSBjb21wbGV4IGFsZ29yaXRobSB3YXMgZGV2ZWxvcGVkIGluIENvbXBvbmVu
dCBQYXNjYWwgZm9yIHRoZSBuZWVkcyBvZiBwaHlzaWNzIGF0IENFUk4gKHRoZSBzby1jYWxsZWQg
b3B0aW1hbCBqZXQgZmluZGVyKS4gVGhlIGFsZ29yaXRobWljIGV4cGVyaW1lbnRhdGlvbiByZXF1
aXJlZCB3YXMgc2lnbmlmaWNhbnQsIGFuZCBJIGNhbm5vdCBpbWFnaW5lIGhvdyBpdCBjb3VsZCBo
YXZlIGJlZW4gZG9uZSB3aXRoaW4gdGhlIHRpbWUgaXQgdG9vayBpbiBCbGFja2JveCAoNCBmb2N1
c2VkIHdlZWtzKSB3aXRoIGFueSBvdGhlciBsYW5nd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cm9tIHRoZSBhZGRyZXNzLCBieSB3aGljaCB5b3UgYXJlIHN1YnNjcmliZWQs
IHlvdXIgbWVzc2FnZSB3aWxsIGJlIG1vZGVyYXRlZCB0byBhdm9pZCBzcGFtLiBQbGVhc2UgdW5k
ZXJzdGFuZCB0aGF0IG1vZGVyYXRpb24gd2lsbCBvZnRlbiBjYXVzZSBzb21lIGRlbGF5LCBpbiBw
YXJ0aWN1bGFyIG92ZXIgd2Vla2VuZHMgb3IgaG9seWRheXN9fQD9AiBjBJEmoW6BIA=


----boundary-LibPST-iamunique-601988546_-_---
Received on Wed Jan 28 2004 - 15:58:23 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:28:58 UTC