zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 0251b2513307b3d1476db90eaf2da631c9e61981
parent c85a442544fa89458f6e6846333891b36a411733
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Tue,  6 Oct 2009 11:18:03 -0400

AdNoteTest: profile test & absolute file location

Diffstat:
MChangeLog | 3+++
Msrc/CMakeLists.txt | 2++
Msrc/Tests/AdNoteTest.h | 23++++++++++++++++++++++-
3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog @@ -947,3 +947,6 @@ 04 Oct 2009 (Mark McCurry) - fixed Ctest issues +06 Oct 2009 (Mark McCurry) + - Added first simple profiling test + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt @@ -119,6 +119,8 @@ include_directories( ) +#for tests looking for files stored in the source dir +add_definitions(-DSOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") #macro for tests macro(unit_test NAME CXX_FILE FILES) # if (CompileTests) diff --git a/src/Tests/AdNoteTest.h b/src/Tests/AdNoteTest.h @@ -1,12 +1,16 @@ #include <cxxtest/TestSuite.h> #include <iostream> #include <fstream> +#include <ctime> +#include <string> #include "../Misc/Master.h" #include "../Misc/Util.h" #include "../Synth/ADnote.h" #include "../Params/Presets.h" #include "../globals.h" +using namespace std; + class AdNoteTest : public CxxTest::TestSuite { public: @@ -41,7 +45,8 @@ public: //prepare the default settings ADnoteParameters *defaultPreset = new ADnoteParameters(new FFTwrapper(OSCIL_SIZE)); XMLwrapper *wrap = new XMLwrapper(); - wrap->loadXMLfile("src/Tests/guitar-adnote.xmz"); + cout << string(SOURCE_DIR) + string("/Tests/guitar-adnote.xmz") << endl; + wrap->loadXMLfile(string(SOURCE_DIR) + string("/Tests/guitar-adnote.xmz")); TS_ASSERT(wrap->enterbranch("MASTER")); TS_ASSERT(wrap->enterbranch("PART", 0)); TS_ASSERT(wrap->enterbranch("INSTRUMENT")); @@ -127,5 +132,21 @@ public: TS_ASSERT_EQUALS(sampleCount, 9472); } + +#define OUTPUT_PROFILE +#ifdef OUTPUT_PROFILE + void testSpeed() { + + const int samps = 15000; + + int t_on = clock(); // timer before calling func + for(int i=0; i<samps; ++i) + note->noteout(outL, outR); + int t_off = clock(); // timer when func returns + + printf ("AdNoteTest: %f seconds for %d Samples to be generated.\n", + (static_cast<float>(t_off - t_on))/CLOCKS_PER_SEC, samps); + } +#endif };