Blame tests/benchmarks/caps.c

Packit a6ee4b
/* GStreamer
Packit a6ee4b
 * Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
Packit a6ee4b
 *
Packit a6ee4b
 * caps.c: benchmark for caps creation and destruction
Packit a6ee4b
 *
Packit a6ee4b
 * This library is free software; you can redistribute it and/or
Packit a6ee4b
 * modify it under the terms of the GNU Library General Public
Packit a6ee4b
 * License as published by the Free Software Foundation; either
Packit a6ee4b
 * version 2 of the License, or (at your option) any later version.
Packit a6ee4b
 *
Packit a6ee4b
 * This library is distributed in the hope that it will be useful,
Packit a6ee4b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit a6ee4b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit a6ee4b
 * Library General Public License for more details.
Packit a6ee4b
 *
Packit a6ee4b
 * You should have received a copy of the GNU Library General Public
Packit a6ee4b
 * License along with this library; if not, write to the
Packit a6ee4b
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit a6ee4b
 * Boston, MA 02110-1301, USA.
Packit a6ee4b
 */
Packit a6ee4b
Packit a6ee4b
Packit a6ee4b
#include <gst/gst.h>
Packit a6ee4b
Packit a6ee4b
Packit a6ee4b
#define NUM_CAPS 10000
Packit a6ee4b
Packit a6ee4b
#define AUDIO_FORMATS_ALL " { S8, U8, " \
Packit a6ee4b
    "S16LE, S16BE, U16LE, U16BE, " \
Packit a6ee4b
    "S24_32LE, S24_32BE, U24_32LE, U24_32BE, " \
Packit a6ee4b
    "S32LE, S32BE, U32LE, U32BE, " \
Packit a6ee4b
    "S24LE, S24BE, U24LE, U24BE, " \
Packit a6ee4b
    "S20LE, S20BE, U20LE, U20BE, " \
Packit a6ee4b
    "S18LE, S18BE, U18LE, U18BE, " \
Packit a6ee4b
    "F32LE, F32BE, F64LE, F64BE }"
Packit a6ee4b
Packit a6ee4b
#define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
Packit a6ee4b
  "audio/x-raw, " \
Packit a6ee4b
  "format = (string) " AUDIO_FORMATS_ALL ", " \
Packit a6ee4b
  "rate = (int) [ 1, MAX ], " \
Packit a6ee4b
  "channels = (int) [ 1, MAX ]"
Packit a6ee4b
Packit a6ee4b
Packit a6ee4b
gint
Packit a6ee4b
main (gint argc, gchar * argv[])
Packit a6ee4b
{
Packit a6ee4b
  GstCaps **capses;
Packit a6ee4b
  GstCaps *protocaps;
Packit a6ee4b
  GstClockTime start, end;
Packit a6ee4b
  gint i;
Packit a6ee4b
Packit a6ee4b
  gst_init (&argc, &argv);
Packit a6ee4b
Packit a6ee4b
  protocaps = gst_caps_from_string (GST_AUDIO_INT_PAD_TEMPLATE_CAPS);
Packit a6ee4b
Packit a6ee4b
  start = gst_util_get_timestamp ();
Packit a6ee4b
  capses = g_new (GstCaps *, NUM_CAPS);
Packit a6ee4b
  for (i = 0; i < NUM_CAPS; i++)
Packit a6ee4b
    capses[i] = gst_caps_copy (protocaps);
Packit a6ee4b
  end = gst_util_get_timestamp ();
Packit a6ee4b
  g_print ("%" GST_TIME_FORMAT " - creating %d caps\n",
Packit a6ee4b
      GST_TIME_ARGS (end - start), i);
Packit a6ee4b
Packit a6ee4b
  start = gst_util_get_timestamp ();
Packit a6ee4b
  for (i = 0; i < NUM_CAPS; i++)
Packit a6ee4b
    gst_caps_unref (capses[i]);
Packit a6ee4b
  end = gst_util_get_timestamp ();
Packit a6ee4b
  g_print ("%" GST_TIME_FORMAT " - destroying %d caps\n",
Packit a6ee4b
      GST_TIME_ARGS (end - start), i);
Packit a6ee4b
Packit a6ee4b
  g_free (capses);
Packit a6ee4b
  gst_caps_unref (protocaps);
Packit a6ee4b
Packit a6ee4b
  return 0;
Packit a6ee4b
}