From 62304d57c6a9206d3a98ef12885596e5872c3f08 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 23 Jan 2012 15:01:08 +0000 Subject: Basic process thread profiling code. git-svn-id: svn://localhost/ardour2/branches/3.0@11310 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/run-profiling.sh | 30 +++++ libs/ardour/test/profiling/runpc.cc | 77 ++++++++++++ .../test/profiling/sessions/0tracks/0tracks.ardour | 133 +++++++++++++++++++++ .../profiling/sessions/0tracks/0tracks.history | 2 + libs/ardour/wscript | 32 +++++ 5 files changed, 274 insertions(+) create mode 100644 libs/ardour/run-profiling.sh create mode 100644 libs/ardour/test/profiling/runpc.cc create mode 100644 libs/ardour/test/profiling/sessions/0tracks/0tracks.ardour create mode 100644 libs/ardour/test/profiling/sessions/0tracks/0tracks.history diff --git a/libs/ardour/run-profiling.sh b/libs/ardour/run-profiling.sh new file mode 100644 index 0000000000..e88ca2cf86 --- /dev/null +++ b/libs/ardour/run-profiling.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# +# Run libardour profiling tests. +# + +if [ ! -f './tempo.cc' ]; then + echo "This script must be run from within the libs/ardour directory"; + exit 1; +fi + +srcdir=`pwd` +cd ../../build + +libs='libs' + +export LD_LIBRARY_PATH=$libs/audiographer:$libs/vamp-sdk:$libs/surfaces:$libs/surfaces/control_protocol:$libs/ardour:$libs/midi++2:$libs/pbd:$libs/rubberband:$libs/soundtouch:$libs/gtkmm2ext:$libs/appleutility:$libs/taglib:$libs/evoral:$libs/evoral/src/libsmf:$libs/timecode:/usr/local/lib:/usr/local/lib64:$LD_LIBRARY_PATH + +export ARDOUR_PANNER_PATH=$libs/panners/2in2out:$libs/panners/1in2out:$libs/panners/vbap + +export LD_PRELOAD=/home/carl/src/libfakejack/libjack.so + +if [ "$1" == "--debug" ]; then + gdb ./libs/ardour/run-profiling +elif [ "$1" == "--valgrind" ]; then + valgrind ./libs/ardour/run-profiling +elif [ "$1" == "--callgrind" ]; then + valgrind --tool=callgrind ./libs/ardour/run-profiling +else + ./libs/ardour/run-profiling $* +fi diff --git a/libs/ardour/test/profiling/runpc.cc b/libs/ardour/test/profiling/runpc.cc new file mode 100644 index 0000000000..4b6f75c629 --- /dev/null +++ b/libs/ardour/test/profiling/runpc.cc @@ -0,0 +1,77 @@ +#include +#include "midi++/manager.h" +#include "pbd/textreceiver.h" +#include "pbd/compose.h" +#include "pbd/enumwriter.h" +#include "ardour/session.h" +#include "ardour/audioengine.h" + +using namespace std; +using namespace PBD; +using namespace ARDOUR; + +class TestReceiver : public Receiver +{ +protected: + void receive (Transmitter::Channel chn, const char * str) { + const char *prefix = ""; + + switch (chn) { + case Transmitter::Error: + prefix = ": [ERROR]: "; + break; + case Transmitter::Info: + /* ignore */ + return; + case Transmitter::Warning: + prefix = ": [WARNING]: "; + break; + case Transmitter::Fatal: + prefix = ": [FATAL]: "; + break; + case Transmitter::Throw: + /* this isn't supposed to happen */ + abort (); + } + + /* note: iostreams are already thread-safe: no external + lock required. + */ + + cout << prefix << str << endl; + + if (chn == Transmitter::Fatal) { + exit (9); + } + } +}; + +TestReceiver test_receiver; + +int +main () +{ + string const test_session_path = "../libs/ardour/test/profiling/sessions/0tracks"; + string const test_session_snapshot = "0tracks.ardour"; + + init (false, true); + SessionEvent::create_per_thread_pool ("test", 512); + + test_receiver.listen_to (error); + test_receiver.listen_to (info); + test_receiver.listen_to (fatal); + test_receiver.listen_to (warning); + + AudioEngine* engine = new AudioEngine ("test", ""); + engine->start (); + MIDI::Manager::create (engine->jack ()); + + Session* session = new Session (*engine, test_session_path, test_session_snapshot); + engine->set_session (session); + + for (int i = 0; i < 32768; ++i) { + session->process (64); + } + + return 0; +} diff --git a/libs/ardour/test/profiling/sessions/0tracks/0tracks.ardour b/libs/ardour/test/profiling/sessions/0tracks/0tracks.ardour new file mode 100644 index 0000000000..351ef33d7c --- /dev/null +++ b/libs/ardour/test/profiling/sessions/0tracks/0tracks.ardour @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/ardour/test/profiling/sessions/0tracks/0tracks.history b/libs/ardour/test/profiling/sessions/0tracks/0tracks.history new file mode 100644 index 0000000000..6dd2506a89 --- /dev/null +++ b/libs/ardour/test/profiling/sessions/0tracks/0tracks.history @@ -0,0 +1,2 @@ + + diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 5910c46e0e..b31981ffe0 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -464,6 +464,38 @@ def build(bld): elif bld.env['build_target'] == 'x86_64': testobj.source += [ 'sse_functions_64bit.s' ] + # Profiling + profilingobj = bld(features = 'cxx cxxprogram') + profilingobj.source = ''' + test/dummy_lxvst.cc + test/profiling/runpc.cc + '''.split() + + profilingobj.includes = obj.includes + profilingobj.uselib = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD', + 'SAMPLERATE','XML','LRDF','COREAUDIO'] + profilingobj.use = ['libpbd','libmidipp','libardour'] + profilingobj.name = 'libardour-profiling' + profilingobj.target = 'run-profiling' + profilingobj.install_path = '' + profilingobj.defines = [ + 'PACKAGE="libardour3profile"', + 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"', + 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"', + 'MODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"', + 'LOCALEDIR="' + os.path.join( + os.path.normpath(bld.env['DATADIR']), 'locale') + '"', + 'VAMP_DIR="' + os.path.join( + os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"' + ] + if bld.env['FPU_OPTIMIZATION']: + profilingobj.source += [ 'sse_functions_xmm.cc' ] + if (bld.env['build_target'] == 'i386' + or bld.env['build_target'] == 'i686'): + profilingobj.source += [ 'sse_functions.s' ] + elif bld.env['build_target'] == 'x86_64': + profilingobj.source += [ 'sse_functions_64bit.s' ] + def shutdown(): autowaf.shutdown() -- cgit v1.2.3