source: trunk/third/gstreamer/tests/spidey_bench.c @ 21005

Revision 21005, 2.5 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21004, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
3 *
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.
8 *
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.
13 *
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.
17 */
18
19#include <gst/gst.h>
20
21static GTimeVal start_time;
22gboolean done = FALSE;
23GstClockTime total = 0;
24guint counted = 0;
25
26static void
27handoff (GstElement * fakesink, GstBuffer * data)
28{
29  GTimeVal end_time;
30  GstClockTime diff;
31
32  if (!GST_IS_BUFFER (data))
33    return;
34  g_get_current_time (&end_time);
35  diff = ((GstClockTime) end_time.tv_sec - start_time.tv_sec) * GST_SECOND +
36      ((GstClockTime) end_time.tv_usec -
37      start_time.tv_usec) * (GST_SECOND / G_USEC_PER_SEC);
38  g_print ("time to launch spider pipeline: %" GST_TIME_FORMAT "\n",
39      GST_TIME_ARGS (diff));
40  done = TRUE;
41  /* don't count first try, it loads the plugins */
42  if (counted++)
43    total += diff;
44}
45
46gint
47main (gint argc, gchar * argv[])
48{
49  GstElement *pipeline;
50  guint i, count = 20;
51  gchar *file, *pipeline_str;
52  gchar **bla;
53
54  gst_init (&argc, &argv);
55
56  if (argc < 2) {
57    g_print ("usage : %s <file>\n", argv[0]);
58    return -1;
59  }
60  bla = g_strsplit (argv[1], " ", -1);
61  file = g_strjoinv ("\\ ", bla);
62  pipeline_str =
63      g_strdup_printf
64      ("filesrc location=\"%s\" ! spider ! audio/x-raw-int ! fakesink name = sink",
65      file);
66
67  for (i = 0; i <= count; i++) {
68    GstElement *sink;
69
70    g_get_current_time (&start_time);
71    pipeline = gst_parse_launch (pipeline_str, NULL);
72    sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
73    g_object_set (sink, "signal-handoffs", TRUE, NULL);
74    g_signal_connect (sink, "handoff", (GCallback) handoff, NULL);
75    gst_element_set_state (pipeline, GST_STATE_PLAYING);
76    done = FALSE;
77    while (!done && gst_bin_iterate (GST_BIN (pipeline)));
78    g_object_unref (pipeline);
79  }
80
81  g_print ("\ntime to launch spider pipeline (average): %" GST_TIME_FORMAT "\n",
82      GST_TIME_ARGS (total / count));
83
84  pipeline = NULL;
85  return 0;
86}
Note: See TracBrowser for help on using the repository browser.