From: Wim Taymans Date: Mon, 17 Jun 2013 09:12:51 +0000 (+0200) Subject: tests: add stress test for buffers and pools X-Git-Tag: 1.1.2~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dab63cb6ed16022580568747aaa43824d6eedd77;p=platform%2Fupstream%2Fgstreamer.git tests: add stress test for buffers and pools --- diff --git a/tests/benchmarks/Makefile.am b/tests/benchmarks/Makefile.am index 7e1cb55..3301172 100644 --- a/tests/benchmarks/Makefile.am +++ b/tests/benchmarks/Makefile.am @@ -6,6 +6,7 @@ noinst_PROGRAMS = \ init \ mass-elements \ gstpollstress \ + gstpoolstress \ gstclockstress \ gstbufferstress diff --git a/tests/benchmarks/gstpoolstress.c b/tests/benchmarks/gstpoolstress.c new file mode 100644 index 0000000..7fa9596 --- /dev/null +++ b/tests/benchmarks/gstpoolstress.c @@ -0,0 +1,90 @@ +/* GStreamer + * Copyright (C) <2013> Wim Taymans + * + * 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. + */ + +#include +#include +#include +#include "gst/glib-compat-private.h" + + +gint +main (gint argc, gchar * argv[]) +{ + gint i; + GstBuffer *tmp; + GstBufferPool *pool; + GstClockTime start, end; + guint64 nbuffers; + GstStructure *conf; + + gst_init (&argc, &argv); + + if (argc != 2) { + g_print ("usage: %s \n", argv[0]); + exit (-1); + } + + nbuffers = atoi (argv[1]); + + if (nbuffers <= 0) { + g_print ("number of buffers must be greater than 0\n"); + exit (-3); + } + + /* Let's just make sure the GstBufferClass is loaded ... */ + tmp = gst_buffer_new (); + gst_buffer_unref (tmp); + + pool = gst_buffer_pool_new (); + + conf = gst_buffer_pool_get_config (pool); + gst_buffer_pool_config_set_params (conf, NULL, 1400, 0, 0); + gst_buffer_pool_set_config (pool, conf); + + gst_buffer_pool_set_active (pool, TRUE); + + start = gst_util_get_timestamp (); + for (i = 0; i < nbuffers; i++) { + tmp = gst_buffer_new_allocate (NULL, 1400, NULL); + gst_buffer_unref (tmp); + } + end = gst_util_get_timestamp (); + g_print ("*** total %" GST_TIME_FORMAT " - average %" GST_TIME_FORMAT + " - Done creating %" G_GUINT64_FORMAT " buffers\n", + GST_TIME_ARGS (end - start), + GST_TIME_ARGS ((end - start) / (nbuffers)), nbuffers); + + + start = gst_util_get_timestamp (); + for (i = 0; i < nbuffers; i++) { + gst_buffer_pool_acquire_buffer (pool, &tmp, NULL); + gst_buffer_unref (tmp); + } + end = gst_util_get_timestamp (); + + g_print ("*** total %" GST_TIME_FORMAT " - average %" GST_TIME_FORMAT + " - Done creating %" G_GUINT64_FORMAT " buffers\n", + GST_TIME_ARGS (end - start), + GST_TIME_ARGS ((end - start) / (nbuffers)), nbuffers); + + gst_buffer_pool_set_active (pool, FALSE); + gst_object_unref (pool); + + return 0; +}