From 211fa7aed02f5548d74960c96075f03f9992f44b Mon Sep 17 00:00:00 2001
From: Antti Soininen <soininen@ill.fr>
Date: Fri, 27 Apr 2018 13:22:05 +0200
Subject: [PATCH] Move workspace and algorithm creation out of performance test
 method.

Re #21737
---
 .../test/ReflectometryMomentumTransferTest.h     | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h b/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h
index 89749b373b5..6e0d090613f 100644
--- a/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h
+++ b/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h
@@ -486,12 +486,15 @@ private:
 
 class ReflectometryMomentumTransferTestPerformance : public CxxTest::TestSuite {
 public:
+  void setUp() override {
+    m_reflectedWS = makeWS();
+    m_directWS = m_reflectedWS->clone();
+    m_algorithm = makeAlgorithm(m_reflectedWS, m_directWS);
+  }
+
   void test_performance() {
-    API::MatrixWorkspace_sptr reflectedWS = makeWS();
-    API::MatrixWorkspace_sptr directWS = reflectedWS->clone();
-    auto algorithm = makeAlgorithm(reflectedWS, directWS);
     for (int i = 0; i < 1000; ++i)
-      algorithm->execute();
+      m_algorithm->execute();
   }
 
 private:
@@ -567,6 +570,11 @@ private:
         convertUnits->getProperty("OutputWorkspace");
     return outWS;
   }
+
+private:
+  API::IAlgorithm_sptr m_algorithm;
+  API::MatrixWorkspace_sptr m_directWS;
+  API::MatrixWorkspace_sptr m_reflectedWS;
 };
 
 #endif /* MANTID_ALGORITHMS_REFLECTOMETRYMOMENTUMTRANSFERTEST_H_ */
-- 
GitLab