1.1 --- a/tests/CMakeLists.txt Sun Dec 11 07:33:29 2011 +0100
1.2 +++ b/tests/CMakeLists.txt Sun Dec 11 11:19:39 2011 +0100
1.3 @@ -1,14 +1,20 @@
1.4 INCLUDE_DIRECTORIES(
1.5 ${CMAKE_SOURCE_DIR}/tests
1.6 - # ${CMAKE_BINARY_DIR}/src
1.7 + ${CMAKE_BINARY_DIR}/tests
1.8 )
1.9
1.10 LINK_DIRECTORIES(
1.11 # ${CMAKE_BINARY_DIR}/lemon
1.12 )
1.13
1.14 +SET(DATADIR_PATH ${CMAKE_BINARY_DIR}/data)
1.15 +CONFIGURE_FILE(
1.16 + ${CMAKE_CURRENT_SOURCE_DIR}/paths.cc.cmake
1.17 + ${CMAKE_CURRENT_BINARY_DIR}/paths.cc
1.18 +)
1.19 +
1.20 ADD_EXECUTABLE(circulation
1.21 - circulation.cc main.cc
1.22 + circulation.cc file_main.cc paths.cc
1.23 )
1.24
1.25 TARGET_LINK_LIBRARIES(circulation
2.1 --- a/tests/benchmark_tools.h Sun Dec 11 07:33:29 2011 +0100
2.2 +++ b/tests/benchmark_tools.h Sun Dec 11 11:19:39 2011 +0100
2.3 @@ -6,16 +6,29 @@
2.4 #include<iomanip>
2.5 #include<lemon/time_measure.h>
2.6
2.7 -extern const char test_name[];
2.8 +extern std::string test_name;
2.9 +extern std::string instance_name;
2.10
2.11 -inline void logTime(const std::string &subtest_name, const
2.12 - lemon::TimeStamp &time)
2.13 +extern const std::string DATADIR_PATH;
2.14 +
2.15 +
2.16 +inline void logTime(const std::string &_instance_name,
2.17 + const std::string &subtest_name,
2.18 + const lemon::TimeStamp &time)
2.19 {
2.20 - std::cout << "*** " << test_name << ' ' << subtest_name << ' '
2.21 - << std::setiosflags(std::ios::fixed) << std::setprecision(4)
2.22 + std::cout << "*** " << test_name
2.23 + << ' ' << _instance_name
2.24 + << ' ' << subtest_name
2.25 + << ' ' << std::setiosflags(std::ios::fixed) << std::setprecision(4)
2.26 << time.realTime() << ' '
2.27 << time.realTime()/(time.userTime()+time.systemTime()) - 1.0
2.28 << std::endl;
2.29 }
2.30
2.31 +inline void logTime(const std::string &subtest_name,
2.32 + const lemon::TimeStamp &time)
2.33 +{
2.34 + logTime(instance_name,subtest_name,time);
2.35 +}
2.36 +
2.37 #endif
3.1 --- a/tests/circulation.cc Sun Dec 11 07:33:29 2011 +0100
3.2 +++ b/tests/circulation.cc Sun Dec 11 11:19:39 2011 +0100
3.3 @@ -4,15 +4,14 @@
3.4 #include <lemon/lgf_reader.h>
3.5 #include <lemon/dimacs.h>
3.6 #include <lemon/error.h>
3.7 +#include <istream>
3.8
3.9 -const char test_name[] = "circulation";
3.10 +std::string test_name = "circulation";
3.11
3.12 using namespace lemon;
3.13
3.14 -int testMain(int argc, char **argv)
3.15 +int testMain(std::istream &input)
3.16 {
3.17 - if(argc!=2) exit(1);
3.18 -
3.19 typedef int Value;
3.20
3.21 SmartDigraph g;
3.22 @@ -24,14 +23,12 @@
3.23
3.24 Timer ti;
3.25 try {
3.26 - std::ifstream input;
3.27 - input.open(argv[1]);
3.28 readDimacsMin(input, g, lo_cap, up_cap, cost, sup);
3.29 } catch (FormatError& error) {
3.30 std::cerr << error.what() << std::endl;
3.31 return 1;
3.32 }
3.33 - logTime("file-read",ti);
3.34 + logTime("fread",ti);
3.35
3.36 Timer tf;
3.37 ti.restart();
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/tests/file_main.cc Sun Dec 11 11:19:39 2011 +0100
4.3 @@ -0,0 +1,23 @@
4.4 +#include <benchmark_tools.h>
4.5 +#include <istream>
4.6 +#include <lemon/error.h>
4.7 +
4.8 +using namespace lemon;
4.9 +
4.10 +std::string instance_name;
4.11 +
4.12 +int testMain(std::istream &input);
4.13 +
4.14 +int main(int argc, char **argv)
4.15 +{
4.16 + if(argc!=2) exit(1);
4.17 +
4.18 + std::ifstream input;
4.19 + input.open((DATADIR_PATH+"/"+argv[1]).c_str());
4.20 +
4.21 + instance_name = argv[1];
4.22 +
4.23 + Timer ti;
4.24 + testMain(input);
4.25 + logTime("total",ti);
4.26 +}
5.1 --- a/tests/main.cc Sun Dec 11 07:33:29 2011 +0100
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,12 +0,0 @@
5.4 -#include <benchmark_tools.h>
5.5 -
5.6 -using namespace lemon;
5.7 -
5.8 -int testMain(int argc, char **argv);
5.9 -
5.10 -int main(int argc, char **argv)
5.11 -{
5.12 - Timer ti;
5.13 - testMain(argc, argv);
5.14 - logTime("total",ti);
5.15 -}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/tests/paths.cc.cmake Sun Dec 11 11:19:39 2011 +0100
6.3 @@ -0,0 +1,4 @@
6.4 +#include <benchmark_tools.h>
6.5 +#include <string>
6.6 +
6.7 +const std::string DATADIR_PATH = "@DATADIR_PATH@";