2 * Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
4 * caps.c: benchmark for caps creation and destruction
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
26 #define NUM_CAPS 10000
28 #define AUDIO_FORMATS_ALL " { S8, U8, " \
29 "S16LE, S16BE, U16LE, U16BE, " \
30 "S24_32LE, S24_32BE, U24_32LE, U24_32BE, " \
31 "S32LE, S32BE, U32LE, U32BE, " \
32 "S24LE, S24BE, U24LE, U24BE, " \
33 "S20LE, S20BE, U20LE, U20BE, " \
34 "S18LE, S18BE, U18LE, U18BE, " \
35 "F32LE, F32BE, F64LE, F64BE }"
37 #define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
39 "format = (string) " AUDIO_FORMATS_ALL ", " \
40 "rate = (int) [ 1, MAX ], " \
41 "channels = (int) [ 1, MAX ]"
45 main (gint argc, gchar * argv[])
49 GstClockTime start, end;
52 gst_init (&argc, &argv);
54 protocaps = gst_caps_from_string (GST_AUDIO_INT_PAD_TEMPLATE_CAPS);
56 start = gst_util_get_timestamp ();
57 capses = g_new (GstCaps *, NUM_CAPS);
58 for (i = 0; i < NUM_CAPS; i++)
59 capses[i] = gst_caps_copy (protocaps);
60 end = gst_util_get_timestamp ();
61 g_print ("%" GST_TIME_FORMAT " - creating %d caps\n",
62 GST_TIME_ARGS (end - start), i);
64 start = gst_util_get_timestamp ();
65 for (i = 0; i < NUM_CAPS; i++)
66 gst_caps_unref (capses[i]);
67 end = gst_util_get_timestamp ();
68 g_print ("%" GST_TIME_FORMAT " - destroying %d caps\n",
69 GST_TIME_ARGS (end - start), i);
72 gst_caps_unref (protocaps);