# HG changeset patch # User Alpar Juttner # Date 1323585209 -3600 # Node ID d7ce0311ece2e6df6e14f477bee8bbd719ae1cd9 # Parent 7768d68909e8da890a81ddad31e559d5e1994428 Some common benchmarking tools added diff -r 7768d68909e8 -r d7ce0311ece2 tests/CMakeLists.txt --- a/tests/CMakeLists.txt Sun Dec 11 06:55:47 2011 +0100 +++ b/tests/CMakeLists.txt Sun Dec 11 07:33:29 2011 +0100 @@ -8,7 +8,7 @@ ) ADD_EXECUTABLE(circulation - circulation.cc + circulation.cc main.cc ) TARGET_LINK_LIBRARIES(circulation diff -r 7768d68909e8 -r d7ce0311ece2 tests/benchmark_tools.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/benchmark_tools.h Sun Dec 11 07:33:29 2011 +0100 @@ -0,0 +1,21 @@ +#ifndef BENCHMARK_TOOLS_H +#define BENCHMARK_TOOLS_H + +#include +#include +#include +#include + +extern const char test_name[]; + +inline void logTime(const std::string &subtest_name, const + lemon::TimeStamp &time) +{ + std::cout << "*** " << test_name << ' ' << subtest_name << ' ' + << std::setiosflags(std::ios::fixed) << std::setprecision(4) + << time.realTime() << ' ' + << time.realTime()/(time.userTime()+time.systemTime()) - 1.0 + << std::endl; +} + +#endif diff -r 7768d68909e8 -r d7ce0311ece2 tests/circulation.cc --- a/tests/circulation.cc Sun Dec 11 06:55:47 2011 +0100 +++ b/tests/circulation.cc Sun Dec 11 07:33:29 2011 +0100 @@ -1,15 +1,15 @@ +#include #include #include #include #include -#include #include const char test_name[] = "circulation"; using namespace lemon; -int main(int argc, char **argv) +int testMain(int argc, char **argv) { if(argc!=2) exit(1); @@ -31,36 +31,41 @@ std::cerr << error.what() << std::endl; return 1; } - std::cerr << "Read the file: " << ti << '\n'; + logTime("file-read",ti); + + Timer tf; ti.restart(); - Circulation,SmartDigraph::ArcMap, SmartDigraph::NodeMap > circ(g,lo_cap,up_cap,sup); - std::cerr << "Setup Circulation class: " << ti << '\n'; + logTime("setup",ti); ti.restart(); bool res = circ.run(); + logTime("alg",ti); + logTime("full",tf); if(res) { - std::cerr << "A feasible circulation is found: " << ti << "\n"; + std::cerr << "A feasible circulation is found\n"; + std::cerr << "Checking...\n"; ti.restart(); bool res2 = circ.checkFlow(); - std::cerr << "Checked in time " << ti << "\n"; + logTime("check",ti); if(res2) - std::cerr << "Success!\nn"; + std::cerr << "Success!\n"; else - std::cerr << "Oops!!!!\n\n"; + std::cerr << "Oops!!!!\n"; } else { - std::cerr << "A dual solution is found: " << ti << "\n"; + std::cerr << "A dual solution is found\n"; + std::cerr << "Checking...\n"; ti.restart(); bool res2 = circ.checkBarrier(); - std::cerr << "Checked in time " << ti << "\n"; + logTime("check",ti); if(res2) - std::cerr << "Success!\nn"; + std::cerr << "Success!\n"; else - std::cerr << "Dual-Oops!!!!\n\n"; + std::cerr << "Dual-Oops!!!!\n"; } } diff -r 7768d68909e8 -r d7ce0311ece2 tests/main.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/main.cc Sun Dec 11 07:33:29 2011 +0100 @@ -0,0 +1,12 @@ +#include + +using namespace lemon; + +int testMain(int argc, char **argv); + +int main(int argc, char **argv) +{ + Timer ti; + testMain(argc, argv); + logTime("total",ti); +}