diff --git a/Processes/DevTools/Analytics/CMakeLists.txt b/Processes/DevTools/Analytics/CMakeLists.txt index 9818a5cca4afaf9a5c7d7fae9210038342df9442..294f0057ef03ba82a9e21ecf9d7cb526b233f859 100644 --- a/Processes/DevTools/Analytics/CMakeLists.txt +++ b/Processes/DevTools/Analytics/CMakeLists.txt @@ -6,6 +6,11 @@ set ( set ( MODEL_HEADERS ExecTime.h + ImplBoundary.h + ImplContinuous.h + ImplDecay.h + ImplInteraction.h + ImplSecondaries.h ) set ( diff --git a/Processes/DevTools/Analytics/ExecTime.h b/Processes/DevTools/Analytics/ExecTime.h index cd43986ebc883becc969dbdbc9de50f24c42a5fe..288e254e167f09457173a01479e60b78c0792dbc 100644 --- a/Processes/DevTools/Analytics/ExecTime.h +++ b/Processes/DevTools/Analytics/ExecTime.h @@ -18,6 +18,12 @@ #include <corsika/process/SecondariesProcess.h> #include <corsika/process/StackProcess.h> +#include <corsika/process/devtools/ImplBoundary.h> +#include <corsika/process/devtools/ImplContinuous.h> +#include <corsika/process/devtools/ImplDecay.h> +#include <corsika/process/devtools/ImplInteraction.h> +#include <corsika/process/devtools/ImplSecondaries.h> + namespace corsika::process { namespace devtools { @@ -71,126 +77,6 @@ namespace corsika::process { double sumTime() const { return cumulatedTime_.count(); } }; - template <class T, bool TCheck> - class Boundary; - - template <class T> - class Boundary<T, false> {}; - - template <class T> - class Boundary<T, true> : public _ExecTimeImpl<T> { - private: - public: - template <typename Particle, typename VTNType> - EProcessReturn DoBoundaryCrossing(Particle& p, VTNType const& from, - VTNType const& to) { - this->start(); - auto r = T::DoBoundaryCrossing(p, from, to); - this->stop(); - return r; - } - }; - - template <class T, bool TCheck> - class Continuous; - - template <class T> - class Continuous<T, false> {}; - - template <class T> - class Continuous<T, true> : public _ExecTimeImpl<T> { - private: - public: - template <typename Particle, typename Track> - EProcessReturn DoContinuous(Particle& p, Track const& t) const { - this->start(); - auto r = T::DoContinous(p, t); - this->stop(); - return r; - } - - template <typename Particle, typename Track> - units::si::LengthType MaxStepLength(Particle const& p, Track const& track) const { - this->start(); - auto r = T::MaxStepLength(p, track); - this->stop(); - return r; - } - }; - - template <class T, bool TCheck> - class Decay; - - template <class T> - class Decay<T, false> {}; - - template <class T> - class Decay<T, true> : public _ExecTimeImpl<T> { - private: - public: - template <typename Particle> - EProcessReturn DoDecay(Particle& p) { - this->start(); - auto r = T::DoDecay(p); - this->stop(); - return r; - } - - template <typename Particle> - corsika::units::si::TimeType GetLifetime(Particle& p) { - this->start(); - auto r = T::GetLifetime(p); - this->stop(); - return r; - } - }; - - template <class T, bool TCheck> - class Interaction; - - template <class T> - class Interaction<T, false> {}; - - template <class T> - class Interaction<T, true> : public _ExecTimeImpl<T> { - private: - public: - template <typename Particle> - EProcessReturn DoInteraction(Particle& p) { - this->start(); - auto r = T::DoInteraction(p); - this->stop(); - return r; - } - - template <typename Particle> - corsika::units::si::GrammageType GetInteractionLength(Particle& p) { - this->start(); - auto r = T::GetInteractionLength(p); - this->stop(); - return r; - } - }; - - template <class T, bool TCheck> - class Secondaries; - - template <class T> - class Secondaries<T, false> {}; - - template <class T> - class Secondaries<T, true> : public _ExecTimeImpl<T> { - private: - public: - template <typename Secondaries> - inline EProcessReturn DoSecondaries(Secondaries& sec) { - this->start(); - auto r = T::DoSecondaries(sec); - this->stop(); - return r; - } - }; - template <typename T> class ExecTime : public Boundary<T, std::is_base_of<corsika::process::BoundaryCrossingProcess< @@ -207,8 +93,8 @@ namespace corsika::process { T, std::is_base_of<corsika::process::InteractionProcess<typename T::_TDerived>, T>::value>, - public Interaction< - T, std::is_base_of<corsika::process::Secondaries<typename T::_TDerived>, + public Secondaries< + T, std::is_base_of<corsika::process::SecondariesProcess<typename T::_TDerived>, T>::value> {}; } // namespace devtools } // namespace corsika::process \ No newline at end of file diff --git a/Processes/DevTools/Analytics/ImplBoundary.h b/Processes/DevTools/Analytics/ImplBoundary.h new file mode 100644 index 0000000000000000000000000000000000000000..7f2ffcb480740fab3037992804ae3c0eb6f40312 --- /dev/null +++ b/Processes/DevTools/Analytics/ImplBoundary.h @@ -0,0 +1,39 @@ +/* + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ +#pragma once +#include <corsika/process/BoundaryCrossingProcess.h> + +#include <corsika/process/devtools/ExecTime.h> + +namespace corsika::process { + namespace devtools { + + template <typename T> + class _ExecTimeImpl; + + template <class T, bool TCheck> + class Boundary; + + template <class T> + class Boundary<T, false> {}; + + template <class T> + class Boundary<T, true> : public _ExecTimeImpl<T> { + private: + public: + template <typename Particle, typename VTNType> + EProcessReturn DoBoundaryCrossing(Particle& p, VTNType const& from, + VTNType const& to) { + this->start(); + auto r = T::DoBoundaryCrossing(p, from, to); + this->stop(); + return r; + } + }; + } // namespace devtools +} // namespace corsika::process \ No newline at end of file diff --git a/Processes/DevTools/Analytics/ImplContinuous.h b/Processes/DevTools/Analytics/ImplContinuous.h new file mode 100644 index 0000000000000000000000000000000000000000..acddf138093b6cdecc150a41c178b4e6b41bdb70 --- /dev/null +++ b/Processes/DevTools/Analytics/ImplContinuous.h @@ -0,0 +1,45 @@ +/* + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ +#pragma once +#include <corsika/process/ContinuousProcess.h> + +#include <corsika/process/devtools/ExecTime.h> + +namespace corsika::process { + namespace devtools { + template <typename T> + class _ExecTimeImpl; + + template <class T, bool TCheck> + class Continuous; + + template <class T> + class Continuous<T, false> {}; + + template <class T> + class Continuous<T, true> : public _ExecTimeImpl<T> { + private: + public: + template <typename Particle, typename Track> + EProcessReturn DoContinuous(Particle& p, Track const& t) const { + this->start(); + auto r = T::DoContinous(p, t); + this->stop(); + return r; + } + + template <typename Particle, typename Track> + units::si::LengthType MaxStepLength(Particle const& p, Track const& track) const { + this->start(); + auto r = T::MaxStepLength(p, track); + this->stop(); + return r; + } + }; + } // namespace devtools +} // namespace corsika::process \ No newline at end of file diff --git a/Processes/DevTools/Analytics/ImplDecay.h b/Processes/DevTools/Analytics/ImplDecay.h new file mode 100644 index 0000000000000000000000000000000000000000..22961f94e30c498d6a56475a4e139782f5942db0 --- /dev/null +++ b/Processes/DevTools/Analytics/ImplDecay.h @@ -0,0 +1,45 @@ +/* + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ +#pragma once +#include <corsika/process/DecayProcess.h> + +#include <corsika/process/devtools/ExecTime.h> + +namespace corsika::process { + namespace devtools { + template <typename T> + class _ExecTimeImpl; + + template <class T, bool TCheck> + class Decay; + + template <class T> + class Decay<T, false> {}; + + template <class T> + class Decay<T, true> : public _ExecTimeImpl<T> { + private: + public: + template <typename Particle> + EProcessReturn DoDecay(Particle& p) { + this->start(); + auto r = T::DoDecay(p); + this->stop(); + return r; + } + + template <typename Particle> + corsika::units::si::TimeType GetLifetime(Particle& p) { + this->start(); + auto r = T::GetLifetime(p); + this->stop(); + return r; + } + }; + } // namespace devtools +} // namespace corsika::process \ No newline at end of file diff --git a/Processes/DevTools/Analytics/ImplInteraction.h b/Processes/DevTools/Analytics/ImplInteraction.h new file mode 100644 index 0000000000000000000000000000000000000000..e6faf403b580a56a7f0e5d983a6d1d803094de34 --- /dev/null +++ b/Processes/DevTools/Analytics/ImplInteraction.h @@ -0,0 +1,45 @@ +/* + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ +#pragma once +#include <corsika/process/InteractionProcess.h> + +#include <corsika/process/devtools/ExecTime.h> + +namespace corsika::process { + namespace devtools { + template <typename T> + class _ExecTimeImpl; + + template <class T, bool TCheck> + class Interaction; + + template <class T> + class Interaction<T, false> {}; + + template <class T> + class Interaction<T, true> : public _ExecTimeImpl<T> { + private: + public: + template <typename Particle> + EProcessReturn DoInteraction(Particle& p) { + this->start(); + auto r = T::DoInteraction(p); + this->stop(); + return r; + } + + template <typename Particle> + corsika::units::si::GrammageType GetInteractionLength(Particle& p) { + this->start(); + auto r = T::GetInteractionLength(p); + this->stop(); + return r; + } + }; + } // namespace devtools +} // namespace corsika::process \ No newline at end of file diff --git a/Processes/DevTools/Analytics/ImplSecondaries.h b/Processes/DevTools/Analytics/ImplSecondaries.h new file mode 100644 index 0000000000000000000000000000000000000000..c2b3cee8061e78e50ad3e926c96dc9fc3aca68b1 --- /dev/null +++ b/Processes/DevTools/Analytics/ImplSecondaries.h @@ -0,0 +1,37 @@ +/* + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ +#pragma once +#include <corsika/process/SecondariesProcess.h> + +#include <corsika/process/devtools/ExecTime.h> + +namespace corsika::process { + namespace devtools { + template <typename T> + class _ExecTimeImpl; + + template <class T, bool TCheck> + class Secondaries; + + template <class T> + class Secondaries<T, false> {}; + + template <class T> + class Secondaries<T, true> : public _ExecTimeImpl<T> { + private: + public: + template <typename Secondaries> + inline EProcessReturn DoSecondaries(Secondaries& sec) { + this->start(); + auto r = T::DoSecondaries(sec); + this->stop(); + return r; + } + }; + } // namespace devtools +} // namespace corsika::process \ No newline at end of file diff --git a/Processes/DevTools/Analytics/testExecTime.cc b/Processes/DevTools/Analytics/testExecTime.cc index f5cd643f77942fa6cbcfaf0dbf026b51890cfdfb..4b5701ffb1c8f4d205b2970cc9e7fc3e641e5cff 100644 --- a/Processes/DevTools/Analytics/testExecTime.cc +++ b/Processes/DevTools/Analytics/testExecTime.cc @@ -33,13 +33,13 @@ TEST_CASE("ContinuousProcess interface", "[proccesses][DevTools ExecTime]") { REQUIRE(execTime.DoBoundaryCrossing(tmp, 0, 0) == EProcessReturn::eOk); auto end = std::chrono::steady_clock::now(); REQUIRE(std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() == - Approx(50).margin(1)); + Approx(50).margin(5)); for (int i = 0; i < 100; i++) execTime.DoBoundaryCrossing(tmp, 0, 0); - REQUIRE(execTime.mean() == Approx(50 * 1000).margin(1 * 1000)); + REQUIRE(execTime.mean() == Approx(50 * 1000).margin(2 * 1000)); - REQUIRE(execTime.sumTime() == Approx(50 * 100 * 1000).margin(100 * 1000)); + REQUIRE(execTime.sumTime() == Approx(50 * 100 * 1000).margin(200 * 1000)); REQUIRE(execTime.var() == Approx(0).margin(20000)); } diff --git a/Processes/DevTools/Dummy/DummyBoundaryCrossingProcess.h b/Processes/DevTools/Dummy/DummyBoundaryCrossingProcess.h index bafff176762745e01876ed8221d15d0f93fc0a4e..475cece83e6ebab7c0fb4b96fb9fe14ef1b5471f 100644 --- a/Processes/DevTools/Dummy/DummyBoundaryCrossingProcess.h +++ b/Processes/DevTools/Dummy/DummyBoundaryCrossingProcess.h @@ -22,8 +22,8 @@ namespace corsika::process { private: public: template <typename Particle, typename VTNType> - EProcessReturn DoBoundaryCrossing(Particle&, VTNType const& from, - VTNType const& to) { + EProcessReturn DoBoundaryCrossing(Particle&, VTNType const&, + VTNType const&) { std::this_thread::sleep_for(std::chrono::milliseconds(ISleep)); return EProcessReturn::eOk; } diff --git a/Processes/DevTools/Dummy/DummyContinuousProcess.h b/Processes/DevTools/Dummy/DummyContinuousProcess.h index 32844732d63ed7bedb18466aab18940af019c4a9..c58794bfbb7ef9c00001056d066a4159884851dd 100644 --- a/Processes/DevTools/Dummy/DummyContinuousProcess.h +++ b/Processes/DevTools/Dummy/DummyContinuousProcess.h @@ -27,7 +27,7 @@ namespace corsika::process { } template <typename Particle, typename Track> - units::si::LengthType MaxStepLength(Particle const& p, Track const& track) const { + units::si::LengthType MaxStepLength(Particle const&, Track const& ) const { std::this_thread::sleep_for(std::chrono::milliseconds(ISleep)); return units::si::meter * std::numeric_limits<double>::infinity(); } diff --git a/Processes/DevTools/Dummy/DummyDecayProcess.h b/Processes/DevTools/Dummy/DummyDecayProcess.h index f30c42eec1cf8451b950c12a7c708fed6d14b356..1b67393074c986c5eb57cc718edf8f811033beee 100644 --- a/Processes/DevTools/Dummy/DummyDecayProcess.h +++ b/Processes/DevTools/Dummy/DummyDecayProcess.h @@ -28,7 +28,7 @@ namespace corsika::process { } template <typename Particle> - corsika::units::si::TimeType GetLifetime(Particle& p) { + corsika::units::si::TimeType GetLifetime(Particle&) { using namespace corsika::units::si; std::this_thread::sleep_for(std::chrono::milliseconds(ISleep)); diff --git a/Processes/DevTools/Dummy/DummyInteractionProcess.h b/Processes/DevTools/Dummy/DummyInteractionProcess.h index cfa6968859cb6f17819ab65defcf8f5cd048fd8f..3e882afb935f9a05e2db315ddeab3a393208f96f 100644 --- a/Processes/DevTools/Dummy/DummyInteractionProcess.h +++ b/Processes/DevTools/Dummy/DummyInteractionProcess.h @@ -27,7 +27,7 @@ namespace corsika::process { } template <typename TParticle> - corsika::units::si::GrammageType GetInteractionLength(TParticle& p) { + corsika::units::si::GrammageType GetInteractionLength(TParticle&) { using namespace corsika::units::si; std::this_thread::sleep_for(std::chrono::milliseconds(ISleep));