tests/: add simple benchmark to test various speeds of fakesrc ! identity ! identity...
authorBenjamin Otte <otte@gnome.org>
Fri, 2 Jul 2004 03:26:44 +0000 (03:26 +0000)
committerBenjamin Otte <otte@gnome.org>
Fri, 2 Jul 2004 03:26:44 +0000 (03:26 +0000)
Original commit message from CVS:
* tests/.cvsignore:
* tests/Makefile.am:
* tests/mass_elements.c: (gst_get_current_time), (main):
add simple benchmark to test various speeds of fakesrc ! identity !
identity ! ... ! fakesink.
Usage: mass_elements [num_identities] [num_buffers]
If not specified they default to 1000.

ChangeLog
tests/.gitignore
tests/Makefile.am
tests/benchmarks/mass-elements.c [new file with mode: 0644]
tests/mass_elements.c [new file with mode: 0644]

index b9de339..1ec799b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2004-07-02  Benjamin Otte  <otte@gnome.org>
 
+       * tests/.cvsignore:
+       * tests/Makefile.am:
+       * tests/mass_elements.c: (gst_get_current_time), (main):
+         add simple benchmark to test various speeds of fakesrc ! identity !
+         identity ! ... ! fakesink.
+         Usage: mass_elements [num_identities] [num_buffers]
+         If not specified they default to 1000.
+
+2004-07-02  Benjamin Otte  <otte@gnome.org>
+
        * gst/gstpad.c: (gst_pad_check_schedulers),
        (gst_pad_can_link_filtered), (gst_pad_link_filtered),
        (gst_pad_link_prepare):
index db17ff7..5429947 100644 (file)
@@ -37,6 +37,7 @@ paramunits
 faketest
 events
 lat
+mass_elements
 *.bb
 *.bbg
 *.da
index ae60d52..4cf093c 100644 (file)
@@ -8,7 +8,7 @@ LAT = lat
 
 endif
 
-noinst_PROGRAMS = $(LAT) spidey_bench
+noinst_PROGRAMS = $(LAT) spidey_bench mass_elements
 
 AM_CFLAGS = $(GST_OBJ_CFLAGS)
 LIBS = $(GST_OBJ_LIBS)
diff --git a/tests/benchmarks/mass-elements.c b/tests/benchmarks/mass-elements.c
new file mode 100644 (file)
index 0000000..9b5d55e
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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>
+
+#define IDENTITY_COUNT (1000)
+#define BUFFER_COUNT (1000)
+
+
+static GstClockTime
+gst_get_current_time (void)
+{
+  GTimeVal tv;
+
+  g_get_current_time (&tv);
+  return GST_TIMEVAL_TO_TIME (tv);
+}
+
+gint
+main (gint argc, gchar * argv[])
+{
+  GstElement *pipeline, *src, *sink, *current, *last;
+  guint i, buffers = BUFFER_COUNT, identities = IDENTITY_COUNT;
+  GstClockTime start, end;
+
+  gst_init (&argc, &argv);
+
+  if (argc > 1)
+    identities = atoi (argv[1]);
+  if (argc > 2)
+    buffers = atoi (argv[2]);
+
+  g_print
+      ("*** benchmarking this pipeline: fakesrc num-buffers=%u ! %u * identity ! fakesink\n",
+      buffers, identities);
+  start = gst_get_current_time ();
+  pipeline = gst_element_factory_make ("pipeline", NULL);
+  g_assert (pipeline);
+  src = gst_element_factory_make ("fakesrc", NULL);
+  g_assert (src);
+  g_object_set (src, "num-buffers", buffers, NULL);
+  sink = gst_element_factory_make ("fakesink", NULL);
+  g_assert (sink);
+  last = src;
+  gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
+  for (i = 0; i < identities; i++) {
+    current = gst_element_factory_make ("identity", NULL);
+    g_assert (current);
+    gst_bin_add (GST_BIN (pipeline), current);
+    if (!gst_element_link (last, current))
+      g_assert_not_reached ();
+    last = current;
+  }
+  if (!gst_element_link (last, sink))
+    g_assert_not_reached ();
+  end = gst_get_current_time ();
+  g_print ("%" GST_TIME_FORMAT " - creating %u identity elements\n",
+      GST_TIME_ARGS (end - start), identities);
+
+  start = gst_get_current_time ();
+  if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+    g_assert_not_reached ();
+  end = gst_get_current_time ();
+  g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
+      GST_TIME_ARGS (end - start));
+
+  start = gst_get_current_time ();
+  while (gst_bin_iterate (GST_BIN (pipeline)));
+  end = gst_get_current_time ();
+  g_print ("%" GST_TIME_FORMAT " - putting %u buffers through\n",
+      GST_TIME_ARGS (end - start), buffers);
+
+  start = gst_get_current_time ();
+  g_object_unref (pipeline);
+  end = gst_get_current_time ();
+  g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n",
+      GST_TIME_ARGS (end - start));
+
+  return 0;
+}
diff --git a/tests/mass_elements.c b/tests/mass_elements.c
new file mode 100644 (file)
index 0000000..9b5d55e
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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>
+
+#define IDENTITY_COUNT (1000)
+#define BUFFER_COUNT (1000)
+
+
+static GstClockTime
+gst_get_current_time (void)
+{
+  GTimeVal tv;
+
+  g_get_current_time (&tv);
+  return GST_TIMEVAL_TO_TIME (tv);
+}
+
+gint
+main (gint argc, gchar * argv[])
+{
+  GstElement *pipeline, *src, *sink, *current, *last;
+  guint i, buffers = BUFFER_COUNT, identities = IDENTITY_COUNT;
+  GstClockTime start, end;
+
+  gst_init (&argc, &argv);
+
+  if (argc > 1)
+    identities = atoi (argv[1]);
+  if (argc > 2)
+    buffers = atoi (argv[2]);
+
+  g_print
+      ("*** benchmarking this pipeline: fakesrc num-buffers=%u ! %u * identity ! fakesink\n",
+      buffers, identities);
+  start = gst_get_current_time ();
+  pipeline = gst_element_factory_make ("pipeline", NULL);
+  g_assert (pipeline);
+  src = gst_element_factory_make ("fakesrc", NULL);
+  g_assert (src);
+  g_object_set (src, "num-buffers", buffers, NULL);
+  sink = gst_element_factory_make ("fakesink", NULL);
+  g_assert (sink);
+  last = src;
+  gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
+  for (i = 0; i < identities; i++) {
+    current = gst_element_factory_make ("identity", NULL);
+    g_assert (current);
+    gst_bin_add (GST_BIN (pipeline), current);
+    if (!gst_element_link (last, current))
+      g_assert_not_reached ();
+    last = current;
+  }
+  if (!gst_element_link (last, sink))
+    g_assert_not_reached ();
+  end = gst_get_current_time ();
+  g_print ("%" GST_TIME_FORMAT " - creating %u identity elements\n",
+      GST_TIME_ARGS (end - start), identities);
+
+  start = gst_get_current_time ();
+  if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+    g_assert_not_reached ();
+  end = gst_get_current_time ();
+  g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
+      GST_TIME_ARGS (end - start));
+
+  start = gst_get_current_time ();
+  while (gst_bin_iterate (GST_BIN (pipeline)));
+  end = gst_get_current_time ();
+  g_print ("%" GST_TIME_FORMAT " - putting %u buffers through\n",
+      GST_TIME_ARGS (end - start), buffers);
+
+  start = gst_get_current_time ();
+  g_object_unref (pipeline);
+  end = gst_get_current_time ();
+  g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n",
+      GST_TIME_ARGS (end - start));
+
+  return 0;
+}