#include <gst/gst.h>
#include "gst/glib-compat-private.h"
+#define BUFFER_SIZE (1400)
gint
main (gint argc, gchar * argv[])
GstBuffer *tmp;
GstBufferPool *pool;
GstClockTime start, end;
+ GstClockTimeDiff dur;
guint64 nbuffers;
GstStructure *conf;
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_config_set_params (conf, NULL, BUFFER_SIZE, 0, 0);
gst_buffer_pool_set_config (pool, conf);
gst_buffer_pool_set_active (pool, TRUE);
+ /* allocate buffers directly */
start = gst_util_get_timestamp ();
for (i = 0; i < nbuffers; i++) {
- tmp = gst_buffer_new_allocate (NULL, 1400, NULL);
+ tmp = gst_buffer_new_allocate (NULL, BUFFER_SIZE, NULL);
gst_buffer_unref (tmp);
}
end = gst_util_get_timestamp ();
+ dur = GST_CLOCK_DIFF (start, end);
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);
-
+ " - Done creating %" G_GUINT64_FORMAT " fresh buffers\n",
+ GST_TIME_ARGS (dur), GST_TIME_ARGS (dur / nbuffers), nbuffers);
+ /* allocate buffers from the pool */
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 ();
-
+ dur = GST_CLOCK_DIFF (start, end);
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);
+ " - Done creating %" G_GUINT64_FORMAT " pooled buffers\n",
+ GST_TIME_ARGS (dur), GST_TIME_ARGS (dur / nbuffers), nbuffers);
gst_buffer_pool_set_active (pool, FALSE);
gst_object_unref (pool);