mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
tests/instantiate/: Add test to test speed of caps copy and free.
Original commit message from CVS: 2005-03-31 Andy Wingo <wingo@pobox.com> * 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.
This commit is contained in:
parent
96d17a3410
commit
123bfb04b3
8 changed files with 181 additions and 4 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
||||||
|
2005-03-31 Andy Wingo <wingo@pobox.com>
|
||||||
|
|
||||||
|
* 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 <wingo@pobox.com>
|
||||||
|
|
||||||
|
* tests/complexity.c: Add a copyright.
|
||||||
|
|
||||||
2005-03-31 Wim Taymans <wim@fluendo.com>
|
2005-03-31 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/base/gstbasetransform.c: (gst_base_transform_base_init),
|
* gst/base/gstbasetransform.c: (gst_base_transform_base_init),
|
||||||
|
|
|
@ -124,7 +124,6 @@ gst_trash_stack_pop (GstTrashStack *stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#warning "using fallback trashstack implementation, performance may suffer"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* generic implementation
|
* generic implementation
|
||||||
|
|
80
tests/benchmarks/caps.c
Normal file
80
tests/benchmarks/caps.c
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
|
||||||
|
*
|
||||||
|
* 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 <gst/gst.h>
|
||||||
|
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
|
* Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
|
||||||
|
* Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public
|
* modify it under the terms of the GNU General Public
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
|
* Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
|
||||||
|
* Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public
|
* modify it under the terms of the GNU General Public
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
noinst_PROGRAMS = create
|
noinst_PROGRAMS = create caps
|
||||||
|
|
||||||
LDADD = $(GST_OBJ_LIBS)
|
LDADD = $(GST_OBJ_LIBS)
|
||||||
AM_CFLAGS = $(GST_OBJ_CFLAGS)
|
AM_CFLAGS = $(GST_OBJ_CFLAGS)
|
||||||
|
|
80
tests/instantiate/caps.c
Normal file
80
tests/instantiate/caps.c
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
|
||||||
|
*
|
||||||
|
* 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 <gst/gst.h>
|
||||||
|
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
|
@ -197,10 +197,10 @@ main (gint argc, gchar * argv[])
|
||||||
g_assert (num_allocs > 0);
|
g_assert (num_allocs > 0);
|
||||||
|
|
||||||
_gmemchunk =
|
_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 ();
|
_gmemchunklock = g_mutex_new ();
|
||||||
_gstmemchunk =
|
_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);
|
g_print ("%d alloc+frees X %d threads\n", num_allocs, num_threads);
|
||||||
time = run_test (gmemchunk_alloc, gmemchunk_free);
|
time = run_test (gmemchunk_alloc, gmemchunk_free);
|
||||||
|
|
Loading…
Reference in a new issue