summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2018-01-31 20:07:06 +0000
committerTim-Philipp Müller <tim@centricular.com>2018-02-19 16:00:52 +0000
commit1ba8cb2207853459191f3748cfd05a2d4a8a3d40 (patch)
tree4b4e3fa6f4dbde1eb69dd9a9f372074c751909ef
parentca6c8971a64147ced769f9a4de5783f0e957b061 (diff)
icles: add appsink and appsrc benchmarks
These are very much artificial of course, but got to measure something. appsink one contains lots of buffer creation/free overhead, while appsrc one does not.
-rw-r--r--tests/icles/.gitignore2
-rw-r--r--tests/icles/Makefile.am18
-rw-r--r--tests/icles/benchmark-appsink.c53
-rw-r--r--tests/icles/benchmark-appsrc.c58
4 files changed, 130 insertions, 1 deletions
diff --git a/tests/icles/.gitignore b/tests/icles/.gitignore
index 0f6dc944c..51f9fe280 100644
--- a/tests/icles/.gitignore
+++ b/tests/icles/.gitignore
@@ -1,4 +1,6 @@
audio-trickplay
+benchmark-appsink
+benchmark-appsrc
input-selector-test
output-selector-test
playbin-text
diff --git a/tests/icles/Makefile.am b/tests/icles/Makefile.am
index f489cd4f8..a51da87ab 100644
--- a/tests/icles/Makefile.am
+++ b/tests/icles/Makefile.am
@@ -1,6 +1,22 @@
SUBDIRS = playback
DIST_SUBDIRS = playback
+benchmark_appsink_SOURCES = benchmark-appsink.c
+benchmark_appsink_CFLAGS = \
+ $(GST_PLUGINS_BASE_CFLAGS) \
+ $(GST_CFLAGS)
+benchmark_appsink_LDADD = \
+ $(top_builddir)/gst-libs/gst/app/libgstapp-$(GST_API_VERSION).la \
+ $(GST_LIBS)
+
+benchmark_appsrc_SOURCES = benchmark-appsrc.c
+benchmark_appsrc_CFLAGS = \
+ $(GST_PLUGINS_BASE_CFLAGS) \
+ $(GST_CFLAGS)
+benchmark_appsrc_LDADD = \
+ $(top_builddir)/gst-libs/gst/app/libgstapp-$(GST_API_VERSION).la \
+ $(GST_LIBS)
+
if USE_X
X_TESTS = stress-videooverlay
@@ -103,4 +119,4 @@ test_reverseplay_LDADD = $(GST_LIBS) $(LIBM)
noinst_PROGRAMS = $(X_TESTS) $(PANGO_TESTS) \
audio-trickplay playbin-text position-formats stress-playbin \
test-scale test-box test-effect-switch test-overlay-blending test-reverseplay \
- test-resample
+ test-resample benchmark-appsink benchmark-appsrc
diff --git a/tests/icles/benchmark-appsink.c b/tests/icles/benchmark-appsink.c
new file mode 100644
index 000000000..ff25ea76a
--- /dev/null
+++ b/tests/icles/benchmark-appsink.c
@@ -0,0 +1,53 @@
+/* GStreamer appsink benchmark
+ * Copyright (C) 2018 Tim-Philipp Müller <tim centricular com>
+
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <gst/gst.h>
+#include <gst/app/app.h>
+
+#define NUM_BUFFERS 10000000
+
+int
+main (int argc, char **argv)
+{
+ GstElement *src, *sink, *pipeline;
+ GstSample *sample;
+
+ gst_init (&argc, &argv);
+
+ pipeline = gst_pipeline_new (NULL);
+
+ src = gst_element_factory_make ("fakesrc", NULL);
+ g_object_set (src, "num-buffers", NUM_BUFFERS, NULL);
+
+ sink = gst_element_factory_make ("appsink", NULL);
+
+ gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
+ gst_element_link_many (src, sink, NULL);
+
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+ while ((sample = gst_app_sink_pull_sample (GST_APP_SINK (sink))))
+ gst_sample_unref (sample);
+
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+
+ return 0;
+}
diff --git a/tests/icles/benchmark-appsrc.c b/tests/icles/benchmark-appsrc.c
new file mode 100644
index 000000000..42151d7df
--- /dev/null
+++ b/tests/icles/benchmark-appsrc.c
@@ -0,0 +1,58 @@
+/* GStreamer appsink benchmark
+ * Copyright (C) 2018 Tim-Philipp Müller <tim centricular com>
+
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <gst/gst.h>
+#include <gst/app/app.h>
+
+#define NUM_BUFFERS 40000000
+
+int
+main (int argc, char **argv)
+{
+ GstElement *src, *sink, *pipeline;
+ GstBuffer *buf;
+ gint i;
+
+ gst_init (&argc, &argv);
+
+ pipeline = gst_pipeline_new (NULL);
+
+ src = gst_element_factory_make ("appsrc", NULL);
+ sink = gst_element_factory_make ("fakesink", NULL);
+
+ gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
+ gst_element_link_many (src, sink, NULL);
+
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+
+ buf = gst_buffer_new ();
+
+ for (i = 0; i < NUM_BUFFERS; ++i) {
+ gst_app_src_push_buffer (GST_APP_SRC (src), gst_buffer_ref (buf));
+ }
+ gst_app_src_end_of_stream (GST_APP_SRC (src));
+
+ gst_buffer_unref (buf);
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+
+ return 0;
+}