2005-03-31 15:00:11 +00:00
|
|
|
/* 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
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2005-03-31 15:00:11 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define NUM_CAPS 10000
|
|
|
|
|
2012-09-13 09:35:41 +00:00
|
|
|
#define AUDIO_FORMATS_ALL " { S8, U8, " \
|
|
|
|
"S16LE, S16BE, U16LE, U16BE, " \
|
|
|
|
"S24_32LE, S24_32BE, U24_32LE, U24_32BE, " \
|
|
|
|
"S32LE, S32BE, U32LE, U32BE, " \
|
|
|
|
"S24LE, S24BE, U24LE, U24BE, " \
|
|
|
|
"S20LE, S20BE, U20LE, U20BE, " \
|
|
|
|
"S18LE, S18BE, U18LE, U18BE, " \
|
|
|
|
"F32LE, F32BE, F64LE, F64BE }"
|
2005-03-31 15:00:11 +00:00
|
|
|
|
|
|
|
#define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
|
2012-09-13 09:35:41 +00:00
|
|
|
"audio/x-raw, " \
|
|
|
|
"format = (string) " AUDIO_FORMATS_ALL ", " \
|
2005-03-31 15:00:11 +00:00
|
|
|
"rate = (int) [ 1, MAX ], " \
|
2012-09-13 09:35:41 +00:00
|
|
|
"channels = (int) [ 1, MAX ]"
|
2005-03-31 15:00:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2010-05-18 14:51:01 +00:00
|
|
|
start = gst_util_get_timestamp ();
|
2005-03-31 15:00:11 +00:00
|
|
|
capses = g_new (GstCaps *, NUM_CAPS);
|
|
|
|
for (i = 0; i < NUM_CAPS; i++)
|
|
|
|
capses[i] = gst_caps_copy (protocaps);
|
2010-05-18 14:51:01 +00:00
|
|
|
end = gst_util_get_timestamp ();
|
2005-03-31 15:00:11 +00:00
|
|
|
g_print ("%" GST_TIME_FORMAT " - creating %d caps\n",
|
|
|
|
GST_TIME_ARGS (end - start), i);
|
|
|
|
|
2010-05-18 14:51:01 +00:00
|
|
|
start = gst_util_get_timestamp ();
|
2005-03-31 15:00:11 +00:00
|
|
|
for (i = 0; i < NUM_CAPS; i++)
|
|
|
|
gst_caps_unref (capses[i]);
|
2010-05-18 14:51:01 +00:00
|
|
|
end = gst_util_get_timestamp ();
|
2005-03-31 15:00:11 +00:00
|
|
|
g_print ("%" GST_TIME_FORMAT " - destroying %d caps\n",
|
|
|
|
GST_TIME_ARGS (end - start), i);
|
|
|
|
|
|
|
|
g_free (capses);
|
|
|
|
gst_caps_unref (protocaps);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|