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 gst_get_current_time (void)
44 g_get_current_time (&tv);
45 return GST_TIMEVAL_TO_TIME (tv);
50 main (gint argc, gchar * argv[])
54 GstClockTime start, end;
57 gst_init (&argc, &argv);
59 protocaps = gst_caps_from_string (GST_AUDIO_INT_PAD_TEMPLATE_CAPS);
61 start = gst_get_current_time ();
62 capses = g_new (GstCaps *, NUM_CAPS);
63 for (i = 0; i < NUM_CAPS; i++)
64 capses[i] = gst_caps_copy (protocaps);
65 end = gst_get_current_time ();
66 g_print ("%" GST_TIME_FORMAT " - creating %d caps\n",
67 GST_TIME_ARGS (end - start), i);
69 start = gst_get_current_time ();
70 for (i = 0; i < NUM_CAPS; i++)
71 gst_caps_unref (capses[i]);
72 end = gst_get_current_time ();
73 g_print ("%" GST_TIME_FORMAT " - destroying %d caps\n",
74 GST_TIME_ARGS (end - start), i);
77 gst_caps_unref (protocaps);