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., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
26 #define NUM_CAPS 10000
29 #define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
31 "rate = (int) [ 1, MAX ], " \
32 "channels = (int) [ 1, MAX ], " \
33 "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
34 "width = (int) { 8, 16, 24, 32 }, " \
35 "depth = (int) [ 1, 32 ], " \
36 "signed = (boolean) { true, false }"
40 main (gint argc, gchar * argv[])
44 GstClockTime start, end;
47 gst_init (&argc, &argv);
49 protocaps = gst_caps_from_string (GST_AUDIO_INT_PAD_TEMPLATE_CAPS);
51 start = gst_util_get_timestamp ();
52 capses = g_new (GstCaps *, NUM_CAPS);
53 for (i = 0; i < NUM_CAPS; i++)
54 capses[i] = gst_caps_copy (protocaps);
55 end = gst_util_get_timestamp ();
56 g_print ("%" GST_TIME_FORMAT " - creating %d caps\n",
57 GST_TIME_ARGS (end - start), i);
59 start = gst_util_get_timestamp ();
60 for (i = 0; i < NUM_CAPS; i++)
61 gst_caps_unref (capses[i]);
62 end = gst_util_get_timestamp ();
63 g_print ("%" GST_TIME_FORMAT " - destroying %d caps\n",
64 GST_TIME_ARGS (end - start), i);
67 gst_caps_unref (protocaps);