2 * Copyright (C) 2016 Stefan Sauer <ensonic@users.sf.net>
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 FITcreating %d capsNESS 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.
22 /* to check the sizes run:
24 * GST_DEBUG="default:7" GST_DEBUG_FILE=trace.log ./tracerserialize
26 * grep "log_gst_structure" trace.log >tracerserialize.gststructure.log
27 * grep "log_g_variant" trace.log >tracerserialize.gvariant.log
33 #define NUM_LOOPS 100000
36 log_gst_structure (const gchar * name, const gchar * first, ...)
42 va_start (var_args, first);
43 s = gst_structure_new_valist (name, first, var_args);
44 l = gst_structure_to_string (s);
47 gst_structure_free (s);
52 log_g_variant (const gchar * format, ...)
58 va_start (var_args, format);
59 v = g_variant_new_va (format, NULL, &var_args);
60 l = g_variant_print (v, FALSE);
68 main (gint argc, gchar * argv[])
70 GstClockTime start, end;
73 gst_init (&argc, &argv);
75 start = gst_util_get_timestamp ();
76 for (i = 0; i < NUM_LOOPS; i++) {
77 log_gst_structure ("name",
78 "ts", G_TYPE_UINT64, (guint64) 0,
79 "index", G_TYPE_UINT, 10,
80 "test", G_TYPE_STRING, "hallo",
81 "flag", GST_TYPE_PAD_DIRECTION, GST_PAD_SRC, NULL);
83 end = gst_util_get_timestamp ();
84 g_print ("%" GST_TIME_FORMAT ": GstStructure\n", GST_TIME_ARGS (end - start));
86 start = gst_util_get_timestamp ();
87 for (i = 0; i < NUM_LOOPS; i++) {
88 log_g_variant ("(stusu)", "name", (guint64) 0, 10, "hallo", GST_PAD_SRC);
90 end = gst_util_get_timestamp ();
91 g_print ("%" GST_TIME_FORMAT ": GVariant\n", GST_TIME_ARGS (end - start));