You're C code doesn't use GObject, so why are you comparing it to GObject? GObject provides more functionality than your code, including thread safe reference counting, which is also taking time up in the profile.
AFAIK Gobject objects creation in Vala is using the general method of calling g_type_create_instance(). The parameter here is the type of an object. It is certainly more heavy than just allocating memory and calling one function (the constructor). Here we probably get object description from a type, call the (referenced by pointer in the GType) constructor, implement interfaces (although there may be none)... I conducted once performance tests (around vala 0.8) and compared with C++. Creating an empty class (no methods or fields) in C++ was about 5 times faster compared to typed class in vala, and 15 times faster than creating class inheriting from Object in vala. Well, my memory may be wrong, but the numbers were around these values. But the conclusion, conclusion: GObject is to blame. GType is to blame. GObject performance is slow (BTW there were some performance refactorings recently, which version of GLib are you using?). Vala can do nothing with it. I did not use dova, but from the measurements it seems that it won't be comparable to C++. Too bad, in the world of object programming where everything is an object, and typical program is based on CREATING much objects and calling a few methods on them, and not the other way (calling much methods on a few objects). best regards, AW.
On 01/14/2011 02:25 PM, Jonathan Ryan wrote:Second of all each iteration your object is being unreferenced. If do you a profile, ~6% of that time is being spent unreferening the object. This could also expalin the differences in time considering C#'s garbage collector does not use reference counting as does GObject, so it's problaby not deallocating those new objects you create them each loop, which would increase the time signifiacantly. On 01/14/2011 02:17 PM, Jonathan Ryan wrote:First of all your "Objects" aren't GObjects, you need to private class TestObject : Object for them to be GObjects. The generated code is much different. On 01/14/2011 11:28 AM, Marco Trevisan (Treviño) wrote:I'm doing some benchmarks with Vala, but I found that its performances aren't so great as I expected when a class is used, and mostly when it's allocated/referenced multiple times... Consider, for example, the simple example attached... The source simply allocates many TestObject's, referencing them in varius ways, and then freeing them after some time. Maybe it's not perfect, but it does what I wanted. However, also if the created object is very simple Vala with the gobject profile it's quite slow. In fact, also if with the results can't be compared to the hand-written C attached code (I've written it fastly, maybe it has errors :P), comparing Vala+Gobject and Vala+Dova underlines some differences: | N | Vala-Gobject | Vala-Dova | Handwritten C | Mono C# | |-------------+----------------+--------------+--------------------------| | 5000000 | 2.367s | 0.952s | 0.310s | 0.404s | |-------------+----------------+--------------+---------------+----------| | 50000000 | 24.224s | 10.152s | 3.169s | 3.662s | |-------------+----------------+--------------+---------------+----------| | 100000000 | 48.402s | 20.364s | 6.126s | 7.112s | |------------------------------------------------------------------------| Now, the C code can't be beaten, of course, but if you compare the Gobject profile to the Dova one (also if it's immature), there's a great performance gap! And this gobject slowness is underlined in other more complex benchmarks, compared to Dova too... I guess that a gobject structure is really more complex compared to the ones defined by Dova (or by simple C), but if Vala has these performances, due to GObject mamangement, even the (evil) Mono C# seems to be better (code attached, ported from the Vala syntax). So, how to improve this? Is really everything related to gobject or is it also Vala which has responsibilities in this? _______________________________________________ vala-list mailing list vala-list gnome org http://mail.gnome.org/mailman/listinfo/vala-list_______________________________________________ vala-list mailing list vala-list gnome org http://mail.gnome.org/mailman/listinfo/vala-list_______________________________________________ vala-list mailing list vala-list gnome org http://mail.gnome.org/mailman/listinfo/vala-list
-- Mój klucz publiczny o identyfikatorze 1024D/E12C5A4C znajduje się na serwerze hkp://keys.gnupg.net My public key with signature 1024D/E12C5A4C is on the server hkp://keys.gnupg.net
Attachment:
signature.asc
Description: PGP signature