I was evaluating use of GObject for small plentiful short-lived objects in libgck. I wanted to see how their performance compared to custom reference counted structures. Turns out it’s not as bad as I imagined.
The speed difference on my system, with a simple test program, ended
up being around a factor of eight. Most of that cost is due to
pthread_mutex_lock
and pthread_mutex_unlock
.
$ ./test-gobject-speed
struct x 10000000 = 1.091700
object x 10000000 = 8.578848
Note that I didn’t use heavy weight stuff like properties or signals in my benchmark. But I don’t need those for this use case.