gobject n_preallocs



i tried to set n_preallocs to 0, 100, 1000, etc, but it takes always the same time to create objects...

here's an example:

#define NUM 10000

object[0] = (gpointer) dobject_new ();

g_object_set (object[0], "visible", TRUE, NULL); //optional
g_object_set (object[0], "name", "foobar", NULL); //optional

g_timer_elapsed (timer, &ms);
g_print ("creating: %i\n", ms);
g_timer_reset (timer);

for (i = 1; i < NUM; i++)
{
	object[i] = (gpointer) dobject_new ();

	g_object_set (object[i], "visible", TRUE, NULL); //optional
	g_object_set (object[i], "name", "foobar", NULL); //optional
}

g_timer_elapsed (timer, &ms);
g_print ("creating: %i\n", ms);
g_timer_reset (timer);

for (i = 0; i < NUM; i++)
{
	g_type_free_instance (object[i]);
}

g_timer_elapsed (timer, &ms);
g_print ("freed: %i\n", ms);

and i get:
1) set n_preallocs to 5000:
creating: 1150
creating: 521214
freed: 5034

1) set n_preallocs to 0:
creating: 1146
creating: 518206
freed: 5536

whats wrong?

tom





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]