Skip to content
Snippets Groups Projects
Commit db6a7ec2 authored by Janik Zikovsky's avatar Janik Zikovsky
Browse files

Refs #2804, #839: Added support for Performance tests in C++ by defining an...

Refs #2804, #839: Added support for Performance tests in C++ by defining an extra test suite in a test .h file. File is added to ctest list if CXXTEST_ADD_PERFORMANCE cmake variable is TRUE. The tests are always built though.
parent 76a83fb7
No related branches found
No related tags found
No related merge requests found
...@@ -90,8 +90,9 @@ ...@@ -90,8 +90,9 @@
# Eliminated superfluous CXXTEST_FOUND assignment # Eliminated superfluous CXXTEST_FOUND assignment
# Cleaned up and added more documentation # Cleaned up and added more documentation
#============================================================= #=============================================================
# CXXTEST_ADD_TEST (public macro) # CXXTEST_ADD_TEST (public macro to add unit tests)
#============================================================= #=============================================================
macro(CXXTEST_ADD_TEST _cxxtest_testname) macro(CXXTEST_ADD_TEST _cxxtest_testname)
# determine the cpp filename # determine the cpp filename
...@@ -135,19 +136,42 @@ macro(CXXTEST_ADD_TEST _cxxtest_testname) ...@@ -135,19 +136,42 @@ macro(CXXTEST_ADD_TEST _cxxtest_testname)
add_test ( NAME ${_cxxtest_testname} add_test ( NAME ${_cxxtest_testname}
COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/bin/Testing" COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/bin/Testing"
$<TARGET_FILE:${_cxxtest_testname}> ) $<TARGET_FILE:${_cxxtest_testname}> )
else (CXXTEST_SINGLE_LOGFILE) else (CXXTEST_SINGLE_LOGFILE)
# THE FOLLOWING DESTROYS THE OUTPUT XML FILE # THE FOLLOWING DESTROYS THE OUTPUT XML FILE
# add each separate test to ctest # add each separate test to ctest
foreach ( part ${ARGN} ) foreach ( part ${ARGN} )
# The filename without extension = The suite name.
get_filename_component(_suitename ${part} NAME_WE ) get_filename_component(_suitename ${part} NAME_WE )
set( _cxxtest_separate_name "${_cxxtest_testname}_${_suitename}") set( _cxxtest_separate_name "${_cxxtest_testname}_${_suitename}")
add_test ( NAME ${_cxxtest_separate_name} add_test ( NAME ${_cxxtest_separate_name}
COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/bin/Testing" COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/bin/Testing"
$<TARGET_FILE:${_cxxtest_testname}> ${_suitename} ) $<TARGET_FILE:${_cxxtest_testname}> ${_suitename} )
if (CXXTEST_ADD_PERFORMANCE)
# ------ Performance test version -------
# Name of the possibly-existing Performance test suite
set( _performance_suite_name "${_suitename}Performance" )
# Read the contents of the header file
FILE( READ ${part} _file_contents )
# Is that suite defined in there at all?
STRING(REGEX MATCH ${_performance_suite_name} _search_res ${_file_contents} )
if (NOT "${_search_res}" STREQUAL "")
#MESSAGE( "${_performance_suite_name} Found: ${_search_res}" )
set( _cxxtest_separate_name "${_cxxtest_testname}_${_performance_suite_name}")
add_test ( NAME ${_cxxtest_separate_name}
COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/bin/Testing"
$<TARGET_FILE:${_cxxtest_testname}> ${_performance_suite_name} )
endif ()
endif ()
endforeach ( part ${ARGN} ) endforeach ( part ${ARGN} )
endif (CXXTEST_SINGLE_LOGFILE) endif (CXXTEST_SINGLE_LOGFILE)
endmacro(CXXTEST_ADD_TEST) endmacro(CXXTEST_ADD_TEST)
#============================================================= #=============================================================
# main() # main()
#============================================================= #=============================================================
......
...@@ -77,6 +77,7 @@ add_subdirectory ( MantidPlot ) ...@@ -77,6 +77,7 @@ add_subdirectory ( MantidPlot )
set ( MAKE_VATES OFF CACHE BOOL "Switch for compiling the Vates project") set ( MAKE_VATES OFF CACHE BOOL "Switch for compiling the Vates project")
set ( MAKE_MDEVENTS OFF CACHE BOOL "Switch for compiling the MDEvents project") set ( MAKE_MDEVENTS OFF CACHE BOOL "Switch for compiling the MDEvents project")
set ( CXXTEST_SINGLE_LOGFILE CACHE BOOL "Switch to have the tests for each package run together") set ( CXXTEST_SINGLE_LOGFILE CACHE BOOL "Switch to have the tests for each package run together")
set ( CXXTEST_ADD_PERFORMANCE OFF CACHE BOOL "Switch to add Performance tests to the list of tests run by ctest?")
if ( MAKE_VATES ) if ( MAKE_VATES )
add_subdirectory ( Vates ) add_subdirectory ( Vates )
......
...@@ -59,7 +59,7 @@ namespace Mantid ...@@ -59,7 +59,7 @@ namespace Mantid
/// overwrite IFunction base class methods /// overwrite IFunction base class methods
std::string name()const{return "CobaltSpinWaveDSHO";} std::string name()const{return "CobaltSpinWaveDSHO";}
/// sqwBroad returns the expected scattering weight for the given Q,w point /// sqwBroad returns the expected scattering weight for the given Q,w point
virtual double CobaltSpinWaveDSHO::sqwBroad(const std::vector<double> & point, const std::vector<double> & fgParams, virtual double sqwBroad(const std::vector<double> & point, const std::vector<double> & fgParams,
const double temp, const Geometry::Matrix<double> & ubinv) const; const double temp, const Geometry::Matrix<double> & ubinv) const;
protected: protected:
......
...@@ -167,6 +167,46 @@ public: ...@@ -167,6 +167,46 @@ public:
//TS_ASSERT_EQUALS(out->getNPoints(), 0); //TODO. Janik. This needs to be fixed. The implicit function should have ensured that no bins were present. //TS_ASSERT_EQUALS(out->getNPoints(), 0); //TODO. Janik. This needs to be fixed. The implicit function should have ensured that no bins were present.
} }
};
class BinToMDHistoWorkspaceTestPerformance : public CxxTest::TestSuite
{
public:
MDEventWorkspace3::sptr in_ws;
void setUp()
{
in_ws = MDEventsHelper::makeMDEW<3>(10, 0.0, 10.0, 1000);
// 1000 boxes with 1000 event each
TS_ASSERT_EQUALS( in_ws->getNPoints(), 1000*1000);
in_ws->splitAllIfNeeded(NULL);
AnalysisDataService::Instance().addOrReplace("BinToMDHistoWorkspaceTest_ws", in_ws);
}
void tearDown()
{
AnalysisDataService::Instance().remove("BinToMDHistoWorkspaceTest_ws");
}
/** A slow test that is useful for profiling and optimizing */
void test_for_profiling()
{
for (size_t i=0; i<1; i++)
{
BinToMDHistoWorkspace alg;
TS_ASSERT_THROWS_NOTHING( alg.initialize() )
TS_ASSERT( alg.isInitialized() )
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("InputWorkspace", "BinToMDHistoWorkspaceTest_ws") );
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("DimX", "Axis0,2.0,8.0, 60"));
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("DimY", "Axis1,2.0,8.0, 60"));
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("DimZ", "Axis2,2.0,8.0, 60"));
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("DimT", "NONE,0.0,10.0,1"));
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "BinToMDHistoWorkspaceTest_ws_histo"));
TS_ASSERT_THROWS_NOTHING( alg.execute(); )
TS_ASSERT( alg.isExecuted() );
}
}
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment