poolstress: code cleanups
authorStefan Sauer <ensonic@users.sf.net>
Wed, 29 Jan 2014 17:21:34 +0000 (18:21 +0100)
committerStefan Sauer <ensonic@users.sf.net>
Wed, 29 Jan 2014 19:37:34 +0000 (20:37 +0100)
Add a few comments. Tell in the results, which number are from which test.

tests/benchmarks/gstpoolstress.c

index 7fa9596..86972c3 100644 (file)
@@ -22,6 +22,7 @@
 #include <gst/gst.h>
 #include "gst/glib-compat-private.h"
 
+#define BUFFER_SIZE (1400)
 
 gint
 main (gint argc, gchar * argv[])
@@ -30,6 +31,7 @@ main (gint argc, gchar * argv[])
   GstBuffer *tmp;
   GstBufferPool *pool;
   GstClockTime start, end;
+  GstClockTimeDiff dur;
   guint64 nbuffers;
   GstStructure *conf;
 
@@ -54,34 +56,34 @@ main (gint argc, gchar * argv[])
   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);