Re: gobject n_preallocs
- From: tom <tom dbservice com>
- To: gtk-devel-list gnome org
- Subject: Re: gobject n_preallocs
- Date: Wed, 15 Jan 2003 19:56:02 +0100
i made a improved test... (file below)
with n_prealloc = 1000:
created: ~200000
freed: ~1500
and n_prealloc = 0:
created: ~150000
freed: ~1500
if you look at this you see that setting n_prealloc even decreases
performance...
file 3dobject.h:
...
struct _DObject
{
GObject parent;
gboolean visible;
gchar *name;
gchar nothing[100 * 1024];
};
...
file main.c:
#include "3dobject.h"
#define NUM 1000
#define RUNS 10
int
main (int argc, char *argv[])
{
gpointer *object[NUM];
int i, j;
GTimer *timer;
gulong ms;
timer = g_timer_new();
g_timer_reset(timer);
//g_timer_start(timer);
for (j = 0; j < RUNS; j++)
{
g_print ("\nrun %i\n", j);
for (i = 0; i < NUM; i++)
{
object[i] = (gpointer) g_object_new (G_TYPE_DOBJECT,
"visible", TRUE, "name", "foobar", NULL);
}
g_timer_elapsed (timer, &ms);
g_print ("created: %i\n", ms);
g_timer_reset (timer);
for (i = 0; i < NUM; i++)
{
g_object_unref(object[i]);
}
g_timer_elapsed (timer, &ms);
g_print ("freed: %i\n", ms);
}
g_timer_destroy(timer);
return (0);
}
--- Begin Message ---
- From: tom <tom dbservice com>
- To: tom <tom dbservice com>
- Subject: Re: gobject n_preallocs
- Date: Wed, 15 Jan 2003 17:18:51 +0100
i made a improved test... (file below)
with n_prealloc = 1000:
created: ~200000
freed: ~1500
and n_prealloc = 0:
created: ~150000
freed: ~1500
if you look at this you see that setting n_prealloc even decreases
performance...
file 3dobject.h:
...
struct _DObject
{
GObject parent;
gboolean visible;
gchar *name;
gchar nothing[100 * 1024];
};
...
file main.c:
#include "3dobject.h"
#define NUM 1000
#define RUNS 10
int
main (int argc, char *argv[])
{
gpointer *object[NUM];
int i, j;
GTimer *timer;
gulong ms;
timer = g_timer_new();
g_timer_reset(timer);
//g_timer_start(timer);
for (j = 0; j < RUNS; j++)
{
g_print ("\nrun %i\n", j);
for (i = 0; i < NUM; i++)
{
object[i] = (gpointer) g_object_new (G_TYPE_DOBJECT,
"visible", TRUE, "name", "foobar", NULL);
}
g_timer_elapsed (timer, &ms);
g_print ("created: %i\n", ms);
g_timer_reset (timer);
for (i = 0; i < NUM; i++)
{
g_object_unref(object[i]);
}
g_timer_elapsed (timer, &ms);
g_print ("freed: %i\n", ms);
}
g_timer_destroy(timer);
return (0);
}
--- End Message ---
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]