Re: gobject n_preallocs



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 ---
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]