/* * tester.cpp * * Created on: Oct 21, 2011 * Author: mike */ #include "tester.hpp" using namespace std; //----------------------------------------------------------------------- HirezTime Tester::measureRuntime(TestFunction test) { sw.reset(); sw.start(); CALL_MEMBER_FN(*this, test)(); sw.stop(); return sw; } // ====================================================================== // Application-specific test code //----------------------------------------------------------------------- // Define static constants const unsigned Tester::defaultSeed = time(0); const int Tester::defaultIterations = 1000000; // 1 million const Tester::TestPair Tester::testSuite[] = { {"Array list:", &Tester::test1}, {"Linked list, composed data:", &Tester::test2}, }; //----------------------------------------------------------------------- void Tester::runOneTest(const TestPair& tp) { HirezTime result = measureRuntime(tp.test); cout << setw(30) << right << tp.name << " " << result << " seconds"<< endl; } //----------------------------------------------------------------------- void Tester::runAllTests() { int num = sizeof(testSuite)/sizeof(TestPair); cout << "Testing lists with " << iterations << " numbers" << " using seed " << seed << "\n" << endl; for (int k=0; knext = new Cell(rand(), NULL); tail = tail->next; } while (head != NULL) { Cell* p = head; head = head->next; delete p; } }