tests/: add benchmark to test how long spider needs to create a pipeline
authorBenjamin Otte <otte@gnome.org>
Sat, 8 May 2004 17:38:24 +0000 (17:38 +0000)
committerBenjamin Otte <otte@gnome.org>
Sat, 8 May 2004 17:38:24 +0000 (17:38 +0000)
Original commit message from CVS:
* tests/Makefile.am:
* tests/spidey_bench.c: (handoff), (main):
add benchmark to test how long spider needs to create a pipeline

ChangeLog
tests/Makefile.am
tests/spidey_bench.c [new file with mode: 0644]

index 86bb7eb..3ee558f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2004-05-08  Benjamin Otte  <otte@gnome.org>
 
+       * tests/Makefile.am:
+       * tests/spidey_bench.c: (handoff), (main):
+         add benchmark to test how long spider needs to create a pipeline
+
+2004-05-08  Benjamin Otte  <otte@gnome.org>
+
        * gst/gstpad.c: (gst_pad_set_active), (gst_pad_link_unnegotiate):
          mark links as unengaged when unnegotiating instead of deactivating.
          This way pads aren't marked as unengaged when going PLAYING=>PAUSED
index b9ee78f..1f46b2b 100644 (file)
@@ -1,12 +1,17 @@
 
 SUBDIRS = instantiate memchunk muxing sched threadstate seeking # bufspeed
 
-if !GST_DISABLE_TRACE
+if GST_DISABLE_TRACE
+noinst_PROGRAMS = 
+else
 noinst_PROGRAMS = lat
 
-lat_CFLAGS = $(GST_OBJ_CFLAGS)
-lat_LDFLAGS = $(GST_OBJ_LIBS)
 endif
 
+noinst_PROGRAMS += spidey_bench
+
+AM_CFLAGS = $(GST_OBJ_CFLAGS)
+LIBS = $(GST_OBJ_LIBS)
+
 EXTRA_DIST = README
 DIST_SUBDIRS= bufspeed instantiate memchunk muxing sched threadstate seeking
diff --git a/tests/spidey_bench.c b/tests/spidey_bench.c
new file mode 100644 (file)
index 0000000..79cdc51
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gst/gst.h>
+
+static GTimeVal start_time;
+gboolean done = FALSE;
+GstClockTime total = 0;
+
+static void
+handoff (GstElement * fakesink, GstBuffer * data)
+{
+  GTimeVal end_time;
+  GstClockTime diff;
+
+  if (!GST_IS_BUFFER (data))
+    return;
+  g_get_current_time (&end_time);
+  diff = ((GstClockTime) end_time.tv_sec - start_time.tv_sec) * GST_SECOND +
+      ((GstClockTime) end_time.tv_usec -
+      start_time.tv_usec) * (GST_SECOND / G_USEC_PER_SEC);
+  g_print ("time to launch spider pipeline: %" GST_TIME_FORMAT "\n",
+      GST_TIME_ARGS (diff));
+  done = TRUE;
+  total += diff;
+}
+
+gint
+main (gint argc, gchar * argv[])
+{
+  GstElement *pipeline;
+  guint i, count = 20;
+  gchar *file, *pipeline_str;
+  gchar **bla;
+
+  gst_init (&argc, &argv);
+
+  if (argc < 2) {
+    g_print ("usage : %s <file>\n", argv[0]);
+    return -1;
+  }
+  bla = g_strsplit (argv[1], " ", -1);
+  file = g_strjoinv ("\\ ", bla);
+  pipeline_str =
+      g_strdup_printf
+      ("filesrc location=\"%s\" ! spider ! audio/x-raw-int ! fakesink name = sink",
+      file);
+
+  for (i = 0; i < count; i++) {
+    GstElement *sink;
+
+    g_get_current_time (&start_time);
+    pipeline = gst_parse_launch (pipeline_str, NULL);
+    sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
+    g_object_set (sink, "signal-handoffs", TRUE, NULL);
+    g_signal_connect (sink, "handoff", (GCallback) handoff, NULL);
+    gst_element_set_state (pipeline, GST_STATE_PLAYING);
+    done = FALSE;
+    while (!done && gst_bin_iterate (GST_BIN (pipeline)));
+    g_object_unref (pipeline);
+  }
+
+  g_print ("\ntime to launch spider pipeline (average): %" GST_TIME_FORMAT "\n",
+      GST_TIME_ARGS (total / count));
+
+  pipeline = NULL;
+  return 0;
+}