po/Makefile.in
check/Makefile
tests/Makefile
-tests/bufspeed/Makefile
tests/instantiate/Makefile
tests/memchunk/Makefile
tests/muxing/Makefile
-SUBDIRS = instantiate memchunk muxing sched threadstate seeking # bufspeed
+SUBDIRS = instantiate memchunk muxing sched threadstate seeking
if GST_DISABLE_TRACE
LAT =
endif
-noinst_PROGRAMS = $(LAT) spidey_bench mass_elements complexity
+noinst_PROGRAMS = $(LAT) mass_elements complexity
AM_CFLAGS = $(GST_OBJ_CFLAGS)
LIBS = $(GST_OBJ_LIBS) \
$(top_builddir)/gst/base/libgstbase-@GST_MAJORMINOR@.la
EXTRA_DIST = README
-DIST_SUBDIRS= bufspeed instantiate memchunk muxing sched threadstate seeking
+DIST_SUBDIRS= instantiate memchunk muxing sched threadstate seeking
+++ /dev/null
-gstbuffer.c
-test1
-test2
-*.bb
-*.bbg
-*.da
+++ /dev/null
-
-noinst_PROGRAMS = test1 test2
-
-test1_SOURCES = test1.c gstbuffer.c gstmempool.c
-
-BUILT_SOURCES = gstbuffer.c
-
-gstbuffer.c:
- cp $(top_srcdir)/gst/gstbuffer.c .
-
-EXTRA_DIST = gstmempool.h
-
-LDADD = $(GST_OBJ_LIBS)
-AM_CFLAGS = $(GST_OBJ_CFLAGS) -I$(top_srcdir)/gst
+++ /dev/null
-benchmark of 5000000 gst_buffer_new/free on 0.2.1 code
-------------------------------------------------------
-gstmemchunk, no lock: real 0m1.309s user 0m1.220s sys 0m0.070s
-gmemchunk, no lock: real 0m3.872s user 0m3.740s sys 0m0.090s
-gstmemchunk, lock: real 0m5.306s user 0m5.160s sys 0m0.100s
-gmemchunk, lock: real 0m8.001s user 0m7.890s sys 0m0.080s
+++ /dev/null
-#include "gstmempool.h"
-#include <string.h> /* memset */
-
-#ifdef __SMP__
-#define POOL_LOCK "lock ; "
-#else
-#define POOL_LOCK ""
-#endif
-
-#define GST_MEM_POOL_AREA(pool) (((GstMemPoolElement*)(pool))->area)
-#define GST_MEM_POOL_DATA(pool) ((gpointer)(((GstMemPoolElement*)(pool)) + 1))
-#define GST_MEM_POOL_LINK(mem) ((GstMemPoolElement*)((guint8*)(mem) - sizeof (GstMemPoolElement)))
-
-#ifdef HAVE_CPU_I386
-#define USE_ASM
-#endif
-
-/*******************************************************
- * area size
- * +-----------------------------------------+
- * pool size
- * +------------+
- *
- * !next!data... !next!data.... !next!data...
- * ! ^ ! ^ !
- * +-------------+ +------------+ +---> NULL
- *
- */
-static gboolean
-populate (GstMemPool * mem_pool)
-{
- guint8 *area;
- gint i;
-
- if (mem_pool->cleanup)
- return FALSE;
-
- area = (guint8 *) g_malloc (mem_pool->area_size);
-
- for (i = 0; i < mem_pool->area_size; i += mem_pool->pool_size) {
- guint8 *areap = area + i;
-
- GST_MEM_POOL_AREA (areap) = (GstMemPoolElement *) area;
-
- if (mem_pool->alloc_func) {
- mem_pool->alloc_func (mem_pool, GST_MEM_POOL_DATA (areap));
- }
-
- gst_mem_pool_free (mem_pool, GST_MEM_POOL_DATA (areap));
- }
-
- return TRUE;
-}
-
-
-GstMemPool *
-gst_mem_pool_new (gchar * name, gint atom_size, gulong area_size, gint type,
- GstMemPoolAllocFunc alloc_func, GstMemPoolFreeFunc free_func)
-{
- GstMemPool *mem_pool;
-
- g_return_val_if_fail (atom_size > 0, NULL);
- g_return_val_if_fail (area_size >= atom_size, NULL);
-
- mem_pool = g_malloc (sizeof (GstMemPool));
-
- mem_pool->pool_size = atom_size + sizeof (GstMemPoolElement);
- area_size = (area_size / atom_size) * mem_pool->pool_size;
-
- mem_pool->name = g_strdup (name);
- mem_pool->free = NULL;
- mem_pool->cnt = 0;
- mem_pool->atom_size = atom_size;
- mem_pool->area_size = area_size;
- mem_pool->cleanup = FALSE;
- mem_pool->alloc_func = alloc_func;
- mem_pool->free_func = free_func;
- mem_pool->chunk_lock = g_mutex_new ();
-
- populate (mem_pool);
-
- return mem_pool;
-}
-
-static gboolean
-free_area (gpointer key, gpointer value, gpointer user_data)
-{
- g_print ("free %p\n", key);
- g_free (key);
-
- return TRUE;
-}
-
-void
-gst_mem_pool_destroy (GstMemPool * mem_pool)
-{
- GHashTable *elements = g_hash_table_new (NULL, NULL);
- gpointer data;
-
- mem_pool->cleanup = TRUE;
-
- data = gst_mem_pool_alloc (mem_pool);
- while (data) {
- GstMemPoolElement *elem = GST_MEM_POOL_LINK (data);
-
- g_hash_table_insert (elements, GST_MEM_POOL_AREA (elem), NULL);
-
- data = gst_mem_pool_alloc (mem_pool);
- }
- g_hash_table_foreach_remove (elements, free_area, NULL);
-
- g_hash_table_destroy (elements);
- g_free (mem_pool->name);
- g_free (mem_pool);
-}
-
-gpointer
-gst_mem_pool_alloc (GstMemPool * mem_pool)
-{
- volatile GstMemPoolElement *pool = NULL;
-
- g_return_val_if_fail (mem_pool != NULL, NULL);
-
-again:
-#if defined(USE_ASM) && defined(HAVE_CPU_I386)
-__asm__ __volatile__ (" testl %%eax, %%eax \n\t" " jz 20f \n" "10: \t" " movl (%%eax), %%ebx \n\t" " movl %%edx, %%ecx \n\t" " incl %%ecx \n\t" POOL_LOCK "cmpxchg8b %1 \n\t" " jz 20f \n\t" " testl %%eax, %%eax \n\t" " jnz 10b \n" "20:\t":"=a" (pool)
-: "m" (*mem_pool), "a" (mem_pool->free), "d" (mem_pool->cnt)
-: "ecx", "ebx");
-#else
- g_mutex_lock (mem_pool->chunk_lock);
- if (mem_pool->free) {
- pool = mem_pool->free;
- mem_pool->free = pool->link;
- }
- g_mutex_unlock (mem_pool->chunk_lock);
-#endif
-
- if (!pool) {
- /*g_print ("extending\n"); */
- if (populate (mem_pool))
- goto again;
- else
- return NULL;
- }
- return GST_MEM_POOL_DATA (pool);
-}
-
-gpointer
-gst_mem_pool_alloc0 (GstMemPool * mem_pool)
-{
- gpointer mem = gst_mem_pool_alloc (mem_pool);
-
- if (mem)
- memset (mem, 0, mem_pool->atom_size);
-
- return mem;
-}
-
-void
-gst_mem_pool_free (GstMemPool * mem_pool, gpointer mem)
-{
- GstMemPoolElement *pool;
-
- g_return_if_fail (mem_pool != NULL);
- g_return_if_fail (mem != NULL);
-
- pool = GST_MEM_POOL_LINK (mem);
-
-#if defined(USE_ASM) && defined(HAVE_CPU_I386)
- __asm__ __volatile__ ("1: \t"
- " movl %2, (%1) \n"
- POOL_LOCK "cmpxchg %1, %0 \n\t"
- " jnz 1b \n\t"::
- "m" (*mem_pool), "r" (pool), "a" (mem_pool->free));
-#else
- g_mutex_lock (mem_pool->chunk_lock);
- pool->link = (GstMemPoolElement *) mem_pool->free;
- mem_pool->free = pool;
- g_mutex_unlock (mem_pool->chunk_lock);
-#endif
-}
+++ /dev/null
-#include <glib.h>
-
-typedef struct _GstMemPool GstMemPool;
-typedef struct _GstMemPoolElement GstMemPoolElement;
-
-typedef void (*GstMemPoolAllocFunc) (GstMemPool *pool, gpointer data);
-typedef void (*GstMemPoolFreeFunc) (GstMemPool *pool, gpointer data);
-
-struct _GstMemPoolElement
-{
- GstMemPoolElement *link; /* next cell in the lifo */
- GstMemPoolElement *area;
-};
-
-struct _GstMemPool
-{
- volatile GstMemPoolElement *free; /* the first free element */
- volatile gulong cnt; /* used to avoid ABA problem */
-
- gchar *name;
- gulong area_size;
- gulong pool_size;
- gulong atom_size;
- gboolean cleanup;
- GstMemPoolAllocFunc alloc_func;
- GstMemPoolFreeFunc free_func;
- GMutex *chunk_lock;
-};
-
-
-GstMemPool* gst_mem_pool_new (gchar *name,
- gint atom_size,
- gulong area_size,
- gint type,
- GstMemPoolAllocFunc alloc_func,
- GstMemPoolFreeFunc free_func);
-
-void gst_mem_pool_destroy (GstMemPool *mem_pool);
-
-gpointer gst_mem_pool_alloc (GstMemPool *mem_pool);
-gpointer gst_mem_pool_alloc0 (GstMemPool *mem_pool);
-void gst_mem_pool_free (GstMemPool *mem_pool,
- gpointer mem);
+++ /dev/null
-#include <gst/gst.h>
-#include "gst/gstbuffer.h"
-#include "gst/gstbufferpool-default.h"
-
-int
-main (int argc, char *argv[])
-{
- GstBuffer *buf;
- guint i;
-
- gst_init (&argc, &argv);
-
- for (i = 0; i < 5000000; i++) {
- buf = gst_buffer_new ();
- gst_buffer_unref (buf);
- }
-
- return 0;
-}
+++ /dev/null
-#include <gst/gst.h>
-
-int
-main (int argc, char *argv[])
-{
- GstBuffer *buf;
- guint i;
-
- gst_init (&argc, &argv);
-
- for (i = 0; i < 5000000; i++) {
- buf = gst_buffer_new ();
- gst_buffer_unref (buf);
- }
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <gst/gst.h>
-
-static GTimeVal start_time;
-gboolean done = FALSE;
-GstClockTime total = 0;
-guint counted = 0;
-
-static void
-handoff (GstElement * fakesink, GstBuffer * data)
-{
- GTimeVal end_time;
- GstClockTime diff;
-
- if (!GST_IS_BUFFER (data))
- return;
- g_get_current_time (&end_time);
- diff = ((GstClockTime) end_time.tv_sec - start_time.tv_sec) * GST_SECOND +
- ((GstClockTime) end_time.tv_usec -
- start_time.tv_usec) * (GST_SECOND / G_USEC_PER_SEC);
- g_print ("time to launch spider pipeline: %" GST_TIME_FORMAT "\n",
- GST_TIME_ARGS (diff));
- done = TRUE;
- /* don't count first try, it loads the plugins */
- if (counted++)
- total += diff;
-}
-
-gint
-main (gint argc, gchar * argv[])
-{
- GstElement *pipeline;
- guint i, count = 20;
- gchar *file, *pipeline_str;
- gchar **bla;
-
- gst_init (&argc, &argv);
-
- if (argc < 2) {
- g_print ("usage : %s <file>\n", argv[0]);
- return -1;
- }
- bla = g_strsplit (argv[1], " ", -1);
- file = g_strjoinv ("\\ ", bla);
- pipeline_str =
- g_strdup_printf
- ("filesrc location=\"%s\" ! spider ! audio/x-raw-int ! fakesink name = sink",
- file);
-
- for (i = 0; i <= count; i++) {
- GstElement *sink;
-
- g_get_current_time (&start_time);
- pipeline = gst_parse_launch (pipeline_str, NULL);
- sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
- g_object_set (sink, "signal-handoffs", TRUE, NULL);
- g_signal_connect (sink, "handoff", (GCallback) handoff, NULL);
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
- done = FALSE;
- while (!done && gst_bin_iterate (GST_BIN (pipeline)));
- g_object_unref (pipeline);
- }
-
- g_print ("\ntime to launch spider pipeline (average): %" GST_TIME_FORMAT "\n",
- GST_TIME_ARGS (total / count));
-
- pipeline = NULL;
- return 0;
-}