From 6df5d52f72e9ee27f20fffe57cb8b373d3b24a5b Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Thu, 10 May 2001 20:30:10 +0000 Subject: [PATCH] Added simple latency tester. Original commit message from CVS: Added simple latency tester. --- test/.gitignore | 2 +- test/Makefile.am | 2 +- test/lat.c | 225 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 227 insertions(+), 2 deletions(-) create mode 100644 test/lat.c diff --git a/test/.gitignore b/test/.gitignore index 5797409..81021e4 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -52,4 +52,4 @@ dvshow video2mp1 mp3mad videotest2 - +lat diff --git a/test/Makefile.am b/test/Makefile.am index 4d1070d..ea89a6a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -12,7 +12,7 @@ noinst_PROGRAMS = qtest $(GNOME_PROGS) record mp3 teardown buffer mp3parse \ mp3play ac3parse ac3play dvdcat fake cobin \ vidcapture avi2mpg mp2tomp1 mp1tomp1 pipetest \ vidcapture2 mp2toavi mp3tovorbis xmmstest \ - mp3mad + mp3mad lat SUBDIRS = xml bindings diff --git a/test/lat.c b/test/lat.c new file mode 100644 index 0000000..fcecd6e --- /dev/null +++ b/test/lat.c @@ -0,0 +1,225 @@ +#include +#include + +__inline__ void lat_read_tsc(guint64 *dst) { +//#ifdef HAVE_RDTS +/* + __asm__ __volatile__ + ("rdtsc" + : "=a" (*(guint32 *)dst), "=d" (*(((guint32 *)dst) + 1)) + : + : "eax", "edx"); +*/ + __asm__ __volatile__ + ("rdtsc" + : "=a" (*(guint32 *)dst), "=d" (*(((guint32 *)dst) + 1)) + : + ); +//#else +// *dst = 0; +//#endif +} + +static guint64 max = 0, min = -1, total = 0; +static guint count = 0; +static guint print_del = 1; +static guint iterations = 0; +static guint mhz = 0; + +void handoff_src(GstElement *src, GstBuffer *buf, gpointer user_data) { + guint64 start; + lat_read_tsc(&start); + GST_BUFFER_TIMESTAMP(buf) = start; +} + +void handoff_sink(GstElement *sink, GstBuffer *buf, gpointer user_data) { + guint64 end, d, avg; + guint avg_ns; + + lat_read_tsc(&end); + d = end - GST_BUFFER_TIMESTAMP(buf); + if (d > max) max = d; + if (d < min) min = d; + total += d; + count++; + avg = total/count; + avg_ns = (guint)(1000.0*(double)avg/(double)mhz); + + if ((count % print_del) == 0) { + g_print("%07d:%08lld min:%08lld max:%08lld avg:%08lld avg-s:0.%09d\r", + count, d, min, max, avg, avg_ns); + } +} + +GstElement *identity_add(GstPipeline *pipeline, GstElement *first, int count) { + GstElement *last, *ident; + int i; + + last = first; + + for (i=0; i