benchmarks: update the tracer benchmark and add a shell benchmark

This commit is contained in:
Stefan Sauer 2016-01-16 13:30:34 +01:00
parent 2d5ba30606
commit 7801a46e5f
2 changed files with 63 additions and 1 deletions

View file

@ -48,6 +48,19 @@ log_gst_structure (const gchar * name, const gchar * first, ...)
va_end (var_args);
}
static void
log_gst_structure_tmpl (const gchar * format, ...)
{
va_list var_args;
va_start (var_args, format);
if (G_LIKELY (GST_LEVEL_TRACE <= _gst_debug_min)) {
gst_debug_log_valist (GST_CAT_DEFAULT, GST_LEVEL_TRACE, __FILE__,
GST_FUNCTION, __LINE__, NULL, format, var_args);
}
va_end (var_args);
}
static void
log_g_variant (const gchar * format, ...)
{
@ -78,6 +91,7 @@ main (gint argc, gchar * argv[])
"ts", G_TYPE_UINT64, (guint64) 0,
"index", G_TYPE_UINT, 10,
"test", G_TYPE_STRING, "hallo",
"bool", G_TYPE_BOOLEAN, TRUE,
"flag", GST_TYPE_PAD_DIRECTION, GST_PAD_SRC, NULL);
}
end = gst_util_get_timestamp ();
@ -85,7 +99,18 @@ main (gint argc, gchar * argv[])
start = gst_util_get_timestamp ();
for (i = 0; i < NUM_LOOPS; i++) {
log_g_variant ("(stusu)", "name", (guint64) 0, 10, "hallo", GST_PAD_SRC);
log_gst_structure_tmpl ("name, ts=(guint64)%" G_GUINT64_FORMAT
", index=(uint)%u, test=(string)%s, bool=(boolean)%s, flag=(GstPadDirection)%d;",
(guint64) 0, 10, "hallo", (TRUE ? "true" : "false"), GST_PAD_SRC);
}
end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT ": GstStructure template\n",
GST_TIME_ARGS (end - start));
start = gst_util_get_timestamp ();
for (i = 0; i < NUM_LOOPS; i++) {
log_g_variant ("(stusbu)", "name", (guint64) 0, 10, "hallo", TRUE,
GST_PAD_SRC);
}
end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT ": GVariant\n", GST_TIME_ARGS (end - start));

37
tests/benchmarks/tracing.sh Executable file
View file

@ -0,0 +1,37 @@
#!/bin/sh
# simple benchmark to check the overhead of the tracers
#
# tracers can be a list of tracers separated using ';'
if [ -z "$1" ]; then
echo "Usage: $0 <tracer(s)> [<file>]"
exit 1
fi
tracer=$1
if [ -z "$2" ]; then
file=$(ls -1R $HOME/Music/ | grep -v "/:" | head -n1)
file=$(ls $HOME/Music/$file)
else
file=$2
fi
echo "testing $tracer on $file"
cat $file >/dev/null
function test() {
GST_DEBUG_FILE=trace.log /usr/bin/gst-launch-1.0 playbin uri=file://$file audio-sink="fakesink sync=false" video-sink="fakesink sync=false" | grep "Execution ended after" | sed 's/Execution ended after//'
}
echo "$tracer"
GST_DEBUG="GST_TRACER:7" GST_TRACE="$tracer" test
GST_DEBUG=
echo "no-log"
GST_TRACER_PLUGINS="$tracer" test
GST_TRACER_PLUGINS=
echo "reference"
test