diff --git a/ChangeLog b/ChangeLog index 5df46bf36f..a257dbdd09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2005-03-31 Andy Wingo + + * tests/instantiate/Makefile.am: + * tests/instantiate/caps.c: Add test to test speed of caps copy + and free. + + * tests/memchunk/gmemchunktest.c (main): Use alloc only on the + GMemChunk to be fair. + + * gst/gsttrashstack.h: Remove warning about using the fallback + trash stack implementation, it's still faster than malloc. + +2005-03-30 Andy Wingo + + * tests/complexity.c: Add a copyright. + 2005-03-31 Wim Taymans * gst/base/gstbasetransform.c: (gst_base_transform_base_init), diff --git a/gst/gsttrashstack.h b/gst/gsttrashstack.h index 7f1c2262b5..9c66499fae 100644 --- a/gst/gsttrashstack.h +++ b/gst/gsttrashstack.h @@ -124,7 +124,6 @@ gst_trash_stack_pop (GstTrashStack *stack) } #else -#warning "using fallback trashstack implementation, performance may suffer" /* * generic implementation diff --git a/tests/benchmarks/caps.c b/tests/benchmarks/caps.c new file mode 100644 index 0000000000..98187addea --- /dev/null +++ b/tests/benchmarks/caps.c @@ -0,0 +1,80 @@ +/* GStreamer + * Copyright (C) 2005 Andy Wingo + * + * caps.c: benchmark for caps creation and destruction + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#include + + +#define NUM_CAPS 10000 + + +#define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \ + "audio/x-raw-int, " \ + "rate = (int) [ 1, MAX ], " \ + "channels = (int) [ 1, MAX ], " \ + "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \ + "width = (int) { 8, 16, 24, 32 }, " \ + "depth = (int) [ 1, 32 ], " \ + "signed = (boolean) { true, false }" + + +static GstClockTime +gst_get_current_time (void) +{ + GTimeVal tv; + + g_get_current_time (&tv); + return GST_TIMEVAL_TO_TIME (tv); +} + + +gint +main (gint argc, gchar * argv[]) +{ + GstCaps **capses; + GstCaps *protocaps; + GstClockTime start, end; + gint i; + + gst_init (&argc, &argv); + + protocaps = gst_caps_from_string (GST_AUDIO_INT_PAD_TEMPLATE_CAPS); + + start = gst_get_current_time (); + capses = g_new (GstCaps *, NUM_CAPS); + for (i = 0; i < NUM_CAPS; i++) + capses[i] = gst_caps_copy (protocaps); + end = gst_get_current_time (); + g_print ("%" GST_TIME_FORMAT " - creating %d caps\n", + GST_TIME_ARGS (end - start), i); + + start = gst_get_current_time (); + for (i = 0; i < NUM_CAPS; i++) + gst_caps_unref (capses[i]); + end = gst_get_current_time (); + g_print ("%" GST_TIME_FORMAT " - destroying %d caps\n", + GST_TIME_ARGS (end - start), i); + + g_free (capses); + gst_caps_unref (protocaps); + + return 0; +} diff --git a/tests/benchmarks/complexity.c b/tests/benchmarks/complexity.c index 8f8cb8adde..58db01b876 100644 --- a/tests/benchmarks/complexity.c +++ b/tests/benchmarks/complexity.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2004 Benjamin Otte + * Copyright (C) 2005 Andy Wingo * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/tests/complexity.c b/tests/complexity.c index 8f8cb8adde..58db01b876 100644 --- a/tests/complexity.c +++ b/tests/complexity.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2004 Benjamin Otte + * Copyright (C) 2005 Andy Wingo * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/tests/instantiate/Makefile.am b/tests/instantiate/Makefile.am index e022f4b45f..5d1482334f 100644 --- a/tests/instantiate/Makefile.am +++ b/tests/instantiate/Makefile.am @@ -1,4 +1,4 @@ -noinst_PROGRAMS = create +noinst_PROGRAMS = create caps LDADD = $(GST_OBJ_LIBS) AM_CFLAGS = $(GST_OBJ_CFLAGS) diff --git a/tests/instantiate/caps.c b/tests/instantiate/caps.c new file mode 100644 index 0000000000..98187addea --- /dev/null +++ b/tests/instantiate/caps.c @@ -0,0 +1,80 @@ +/* GStreamer + * Copyright (C) 2005 Andy Wingo + * + * caps.c: benchmark for caps creation and destruction + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#include + + +#define NUM_CAPS 10000 + + +#define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \ + "audio/x-raw-int, " \ + "rate = (int) [ 1, MAX ], " \ + "channels = (int) [ 1, MAX ], " \ + "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \ + "width = (int) { 8, 16, 24, 32 }, " \ + "depth = (int) [ 1, 32 ], " \ + "signed = (boolean) { true, false }" + + +static GstClockTime +gst_get_current_time (void) +{ + GTimeVal tv; + + g_get_current_time (&tv); + return GST_TIMEVAL_TO_TIME (tv); +} + + +gint +main (gint argc, gchar * argv[]) +{ + GstCaps **capses; + GstCaps *protocaps; + GstClockTime start, end; + gint i; + + gst_init (&argc, &argv); + + protocaps = gst_caps_from_string (GST_AUDIO_INT_PAD_TEMPLATE_CAPS); + + start = gst_get_current_time (); + capses = g_new (GstCaps *, NUM_CAPS); + for (i = 0; i < NUM_CAPS; i++) + capses[i] = gst_caps_copy (protocaps); + end = gst_get_current_time (); + g_print ("%" GST_TIME_FORMAT " - creating %d caps\n", + GST_TIME_ARGS (end - start), i); + + start = gst_get_current_time (); + for (i = 0; i < NUM_CAPS; i++) + gst_caps_unref (capses[i]); + end = gst_get_current_time (); + g_print ("%" GST_TIME_FORMAT " - destroying %d caps\n", + GST_TIME_ARGS (end - start), i); + + g_free (capses); + gst_caps_unref (protocaps); + + return 0; +} diff --git a/tests/memchunk/gmemchunktest.c b/tests/memchunk/gmemchunktest.c index e443cc5f74..e22b761a6e 100644 --- a/tests/memchunk/gmemchunktest.c +++ b/tests/memchunk/gmemchunktest.c @@ -197,10 +197,10 @@ main (gint argc, gchar * argv[]) g_assert (num_allocs > 0); _gmemchunk = - g_mem_chunk_new ("test", CHUNK_SIZE, CHUNK_SIZE * 16, G_ALLOC_AND_FREE); + g_mem_chunk_new ("test", CHUNK_SIZE, CHUNK_SIZE * 16, G_ALLOC_ONLY); _gmemchunklock = g_mutex_new (); _gstmemchunk = - gst_mem_chunk_new ("test", CHUNK_SIZE, CHUNK_SIZE * 16, G_ALLOC_AND_FREE); + gst_mem_chunk_new ("test", CHUNK_SIZE, CHUNK_SIZE * 16, G_ALLOC_ONLY); g_print ("%d alloc+frees X %d threads\n", num_allocs, num_threads); time = run_test (gmemchunk_alloc, gmemchunk_free);