2 * Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #define IDENTITY_COUNT (1000)
22 #define BUFFER_COUNT (1000)
26 gst_get_current_time (void)
30 g_get_current_time (&tv);
31 return GST_TIMEVAL_TO_TIME (tv);
35 main (gint argc, gchar * argv[])
37 GstElement *pipeline, *src, *sink, *current, *last;
38 guint i, buffers = BUFFER_COUNT, identities = IDENTITY_COUNT;
39 GstClockTime start, end;
41 gst_init (&argc, &argv);
44 identities = atoi (argv[1]);
46 buffers = atoi (argv[2]);
49 ("*** benchmarking this pipeline: fakesrc num-buffers=%u ! %u * identity ! fakesink\n",
51 start = gst_get_current_time ();
52 pipeline = gst_element_factory_make ("pipeline", NULL);
54 src = gst_element_factory_make ("fakesrc", NULL);
56 g_object_set (src, "num-buffers", buffers, NULL);
57 sink = gst_element_factory_make ("fakesink", NULL);
60 gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
61 for (i = 0; i < identities; i++) {
62 current = gst_element_factory_make ("identity", NULL);
64 gst_bin_add (GST_BIN (pipeline), current);
65 if (!gst_element_link (last, current))
66 g_assert_not_reached ();
69 if (!gst_element_link (last, sink))
70 g_assert_not_reached ();
71 end = gst_get_current_time ();
72 g_print ("%" GST_TIME_FORMAT " - creating %u identity elements\n",
73 GST_TIME_ARGS (end - start), identities);
75 start = gst_get_current_time ();
76 if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
77 g_assert_not_reached ();
78 end = gst_get_current_time ();
79 g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
80 GST_TIME_ARGS (end - start));
82 start = gst_get_current_time ();
83 while (gst_bin_iterate (GST_BIN (pipeline)));
84 end = gst_get_current_time ();
85 g_print ("%" GST_TIME_FORMAT " - putting %u buffers through\n",
86 GST_TIME_ARGS (end - start), buffers);
88 start = gst_get_current_time ();
89 g_object_unref (pipeline);
90 end = gst_get_current_time ();
91 g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n",
92 GST_TIME_ARGS (end - start));