benchmarks: use gst_util_get_timestamp() instead of own implementation
[platform/upstream/gstreamer.git] / tests / benchmarks / caps.c
1 /* GStreamer
2  * Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
3  *
4  * caps.c: benchmark for caps creation and destruction
5  *
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.
10  *
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.
15  *
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.
20  */
21
22
23 #include <gst/gst.h>
24
25
26 #define NUM_CAPS 10000
27
28
29 #define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
30   "audio/x-raw-int, " \
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 }"
37
38
39 gint
40 main (gint argc, gchar * argv[])
41 {
42   GstCaps **capses;
43   GstCaps *protocaps;
44   GstClockTime start, end;
45   gint i;
46
47   gst_init (&argc, &argv);
48
49   protocaps = gst_caps_from_string (GST_AUDIO_INT_PAD_TEMPLATE_CAPS);
50
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);
58
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);
65
66   g_free (capses);
67   gst_caps_unref (protocaps);
68
69   return 0;
70 }