Skip to content
Snippets Groups Projects
Commit 956c9518 authored by Owen Arnold's avatar Owen Arnold
Browse files

Refs #3444. Add performance tests. Benchmark for future improvements.

parent a4fc6b65
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,9 @@ public:
{
return "vtkMDEWHexahedronFactory";
}
/// Typedef sptr to 3d event workspace.
typedef boost::shared_ptr<Mantid::MDEvents::MDEventWorkspace3> MDEventWorkspace3_sptr;
private:
......@@ -78,8 +81,7 @@ private:
/// Scalar name to provide on dataset.
const std::string m_scalarName;
/// Typedef sptr to 3d event workspace.
typedef boost::shared_ptr<Mantid::MDEvents::MDEventWorkspace3> MDEventWorkspace3_sptr;
/// Member workspace to generate vtkdataset from.
MDEventWorkspace3_sptr m_workspace;
......
......@@ -71,7 +71,7 @@ public:
void testCreateDataSet()
{
IMDEventWorkspace_sptr ws = MDEventsTestHelper::makeMDEW<3>(10, 0.0, 10.0, 1);
vtkMDEWHexahedronFactory::MDEventWorkspace3_sptr ws = MDEventsTestHelper::makeMDEW<3>(10, 0.0, 10.0, 1);
vtkMDEWHexahedronFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 1)), "signal");
factory.initialize(ws);
vtkDataSet* product = NULL;
......@@ -87,6 +87,16 @@ public:
TSM_ASSERT_EQUALS("Wrong number of points to cells. Hexahedron has 8 vertexes.", expected_n_cells * 8, product->GetNumberOfPoints());
TSM_ASSERT_EQUALS("No signal Array", "signal", std::string(product->GetCellData()->GetArray(0)->GetName()));
TSM_ASSERT_EQUALS("Wrong sized signal Array", expected_n_signals, product->GetCellData()->GetArray(0)->GetSize());
/*Check dataset bounds*/
double* bounds = product->GetBounds();
TS_ASSERT_EQUALS(0, bounds[0]);
TS_ASSERT_EQUALS(10, bounds[1]);
TS_ASSERT_EQUALS(0, bounds[2]);
TS_ASSERT_EQUALS(10, bounds[3]);
TS_ASSERT_EQUALS(0, bounds[4]);
TS_ASSERT_EQUALS(10, bounds[5]);
product->Delete();
}
......@@ -97,4 +107,55 @@ public:
};
//=====================================================================================
// Performance tests
//=====================================================================================
class vtkMDEWHexahedronFactoryTestPerformance : public CxxTest::TestSuite
{
private:
vtkMDEWHexahedronFactory::MDEventWorkspace3_sptr m_ws;
public :
void setUp()
{
m_ws = MDEventsTestHelper::makeMDEW<3>(100, 0.0, 100.0, 1);
}
/* Create 1E6 cells*/
void testCreateDataSet()
{
vtkMDEWHexahedronFactory factory(ThresholdRange_scptr(new UserDefinedThresholdRange(0, 1)), "signal");
factory.initialize(m_ws);
vtkDataSet* product = NULL;
TS_ASSERT_THROWS_NOTHING(product = factory.create());
const size_t expected_n_points = 8000000;
const size_t expected_n_cells = 1000000;
const size_t expected_n_signals = expected_n_cells;
TSM_ASSERT_EQUALS("Wrong number of points", expected_n_points, product->GetNumberOfPoints());
TSM_ASSERT_EQUALS("Wrong number of cells", expected_n_cells, product->GetNumberOfCells());
TSM_ASSERT_EQUALS("Wrong number of points to cells. Hexahedron has 8 vertexes.", expected_n_cells * 8, product->GetNumberOfPoints());
TSM_ASSERT_EQUALS("No signal Array", "signal", std::string(product->GetCellData()->GetArray(0)->GetName()));
TSM_ASSERT_EQUALS("Wrong sized signal Array", expected_n_signals, product->GetCellData()->GetArray(0)->GetSize());
/*Check dataset bounds*/
double* bounds = product->GetBounds();
TS_ASSERT_EQUALS(0, bounds[0]);
TS_ASSERT_EQUALS(100, bounds[1]);
TS_ASSERT_EQUALS(0, bounds[2]);
TS_ASSERT_EQUALS(100, bounds[3]);
TS_ASSERT_EQUALS(0, bounds[4]);
TS_ASSERT_EQUALS(100, bounds[5]);
product->Delete();
}
};
#endif
\ No newline at end of file
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