IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 2a41fb40 authored by ralfulrich's avatar ralfulrich
Browse files

clang style

parent 3cbcdd68
No related branches found
No related tags found
No related merge requests found
Showing
with 82 additions and 82 deletions
......@@ -26,7 +26,6 @@
#include <boost/math/quadrature/gauss_kronrod.hpp>
namespace corsika::environment {
/**
......
......@@ -20,23 +20,25 @@
namespace corsika::analytics {
/// Measure the runtime of a single class function
/**
/**
* @tparam TClassFunc Type of the member function pointer that should be wrapped
* @tparam TFunc Actual function of the type defined in TClass
*/
template <typename TClassFunc, TClassFunc TFunc>
class ClassTimer;
/// Measure the runtime of a single class function
/** Specialisation to capture exact information about the composition of the member function pointer used.
*
* This class wrapes a single function and allowes the measureing of its runtime if it called via the "call(...)" function
*
/** Specialisation to capture exact information about the composition of the member
* function pointer used.
*
* This class wrapes a single function and allowes the measureing of its runtime if it
* called via the "call(...)" function
*
* @tparam TClass Class of the function that should be wrapped
* @tparam TRet Return value of the wrapped function
* @tparam TArgs Arguments passed to the wrapped function
* @tparam TFuncPtr Actual function of the type defined by TRet TClass::TFuncPtr(TArgs...)
* @tparam TFuncPtr Actual function of the type defined by TRet
* TClass::TFuncPtr(TArgs...)
*/
template <typename TClass, typename TRet, typename... TArgs,
TRet (TClass::*TFuncPtr)(TArgs...)>
......@@ -54,11 +56,13 @@ namespace corsika::analytics {
ClassTimer(TClass& obj)
: vObj(obj) {}
/// Executes the wrapped function
/** This function executes and measure the runtime of the wrapped function with the highest precision available (high_resolution_clock).
*
/// Executes the wrapped function
/** This function executes and measure the runtime of the wrapped function with the
* highest precision available (high_resolution_clock).
*
* @param args Arguments are perfect forwarded to the wrapped function.
* @return Returns the return value of the wrapped function. This value get copied during the process and therefore must be copie constructible!
* @return Returns the return value of the wrapped function. This value get copied
* during the process and therefore must be copie constructible!
*/
TRet call(TArgs... args) {
vStart = TClock::now();
......@@ -97,7 +101,6 @@ namespace corsika::analytics {
inline TDuration getTime() const { return vDiff; }
};
/// Specialisation for const member functions
template <typename TClass, typename TRet, typename... TArgs,
TRet (TClass::*TFuncPtr)(TArgs...) const>
......@@ -125,7 +128,6 @@ namespace corsika::analytics {
inline TDuration getTime() const { return vDiff; }
};
/// Specialisation for const member functions without return value
template <typename TClass, typename... TArgs, void (TClass::*TFuncPtr)(TArgs...) const>
class ClassTimer<void (TClass::*)(TArgs...) const, TFuncPtr> {
......
......@@ -13,12 +13,12 @@
namespace corsika::analytics {
/// Wraps and measures the runtime of a single function type object
/**
*
* @tparam TFunc funtion pointer that should be wrapped
* @tparam TClock type of the clock that should be used for measurements
* @tparam TDuration type of std::duration to measure the elapsed time
*/
/**
*
* @tparam TFunc funtion pointer that should be wrapped
* @tparam TClock type of the clock that should be used for measurements
* @tparam TDuration type of std::duration to measure the elapsed time
*/
template <typename TFunc, typename TClock = std::chrono::high_resolution_clock,
typename TDuration = std::chrono::microseconds>
class FunctionTimer {
......@@ -29,7 +29,6 @@ namespace corsika::analytics {
TFunc function_;
public:
/// Constructs the wrapper with the given functionpointer
FunctionTimer(TFunc f)
: function_(f) {}
......
......@@ -23,7 +23,6 @@ int testFunc() {
class TestClass {
public:
int operator()() {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
return 31415;
......@@ -46,5 +45,4 @@ TEST_CASE("Analytics", "[Timer]") {
std::cout << test() << std::endl;
std::cout << test.getTime().count() << std::endl;
}
}
......@@ -22,7 +22,7 @@ namespace corsika::process {
are of type BaseProcess<T>
*/
class _BaseProcess{};
class _BaseProcess {};
template <typename TDerived>
class BaseProcess : _BaseProcess {
......@@ -36,9 +36,9 @@ namespace corsika::process {
TDerived& GetRef() { return static_cast<TDerived&>(*this); }
const TDerived& GetRef() const { return static_cast<const TDerived&>(*this); }
public:
// Base processor type for use in other template classes
using TProcessType = TDerived;
public:
// Base processor type for use in other template classes
using TProcessType = TDerived;
};
} // namespace corsika::process
......@@ -19,8 +19,7 @@ namespace corsika::process {
class BoundaryCrossingProcess : public BaseProcess<TDerived> {
private:
protected:
public:
public:
/**
* This method is called when a particle crosses the boundary between the nodes
* \p from and \p to.
......
......@@ -27,8 +27,7 @@ namespace corsika::process {
class ContinuousProcess : public BaseProcess<TDerived> {
private:
protected:
public:
public:
// here starts the interface part
// -> enforce TDerived to implement DoContinuous...
template <typename TParticle, typename TTrack>
......
......@@ -26,8 +26,7 @@ namespace corsika::process {
template <typename TDerived>
struct DecayProcess : BaseProcess<TDerived> {
public:
public:
using BaseProcess<TDerived>::GetRef;
/// here starts the interface-definition part
......
......@@ -26,11 +26,9 @@ namespace corsika::process {
template <typename TDerived>
class InteractionProcess : public BaseProcess<TDerived> {
public:
public:
using BaseProcess<TDerived>::GetRef;
/// here starts the interface-definition part
// -> enforce TDerived to implement DoInteraction...
template <typename TParticle>
......
......@@ -26,8 +26,7 @@ namespace corsika::process {
template <typename TDerived>
class SecondariesProcess : public BaseProcess<TDerived> {
public:
public:
/// here starts the interface-definition part
// -> enforce TDerived to implement DoSecondaries...
template <typename TSecondaries>
......
......@@ -25,11 +25,10 @@ namespace corsika::process {
*/
template <typename TDerived>
class StackProcess : public BaseProcess<TDerived>{
class StackProcess : public BaseProcess<TDerived> {
private:
protected:
public:
StackProcess() = delete;
StackProcess(const unsigned int nStep)
: fNStep(nStep) {}
......
......@@ -30,34 +30,36 @@ namespace corsika::process {
namespace analytic_processors {
/// Time measurement of individual processes
/** This class allowes to log the runtime spend in all default calls to the process.
* No distinction is made between individual function calls of the process, the runtime is accumulated
* and or avaraged without differentiation.
*
* The class is currently only implemented for BoundaryProcess, ContinuousProcess, DecayProcess, InteractionProcess and SecondariesProcess and captures only the according functions of the base class given as template parameter. Trying to access BoundaryProcess functions with a DecayProcess as template parameter will currently give long errormessages.
*
* Inherits all functionality of the class that should be measured, this includes functions like getters and setters
/** This class allowes to log the runtime spend in all default calls to the process.
* No distinction is made between individual function calls of the process, the
* runtime is accumulated and or avaraged without differentiation.
*
* The class is currently only implemented for BoundaryProcess, ContinuousProcess,
* DecayProcess, InteractionProcess and SecondariesProcess and captures only the
* according functions of the base class given as template parameter. Trying to access
* BoundaryProcess functions with a DecayProcess as template parameter will currently
* give long errormessages.
*
* Inherits all functionality of the class that should be measured, this includes
* functions like getters and setters
*/
template <typename T>
class ExecTime
: public Boundary<T, std::is_base_of<corsika::process::BoundaryCrossingProcess<
typename T::TProcessType>,
T>::value>,
public Continuous<
T,
std::is_base_of<corsika::process::ContinuousProcess<typename T::TProcessType>,
T>::value>,
public Continuous<T, std::is_base_of<corsika::process::ContinuousProcess<
typename T::TProcessType>,
T>::value>,
public Decay<
T, std::is_base_of<corsika::process::DecayProcess<typename T::TProcessType>,
T>::value>,
public Interaction<
T,
std::is_base_of<corsika::process::InteractionProcess<typename T::TProcessType>,
T>::value>,
public Secondaries<
T,
std::is_base_of<corsika::process::SecondariesProcess<typename T::TProcessType>,
T>::value> {
public Interaction<T, std::is_base_of<corsika::process::InteractionProcess<
typename T::TProcessType>,
T>::value>,
public Secondaries<T, std::is_base_of<corsika::process::SecondariesProcess<
typename T::TProcessType>,
T>::value> {
static_assert(std::is_base_of<corsika::process::_BaseProcess, T>::value,
"error message");
......
......@@ -31,11 +31,13 @@ namespace corsika::process {
namespace detail {
/// Process type independent functionality of the Process runtime measurement class ExecTime
/** Inherits all functionality of the class that should be sampled, this includes special functions for getters and setters
*
*
*
/// Process type independent functionality of the Process runtime measurement class
/// ExecTime
/** Inherits all functionality of the class that should be sampled, this includes
* special functions for getters and setters
*
*
*
*/
template <typename T>
class ExecTimeImpl : public T {
......@@ -74,7 +76,8 @@ namespace corsika::process {
this->update(timeDiv);
}
/// Updates the floating mean and variance as well as the global min and max of the sampled runtimes
/// Updates the floating mean and variance as well as the global min and max of
/// the sampled runtimes
void update(std::chrono::duration<double, std::micro> timeDif) {
cumulatedTime_ += timeDif;
......
......@@ -36,11 +36,12 @@ namespace corsika::process {
EProcessReturn DoBoundaryCrossing(Particle& p, VTNType const& from,
VTNType const& to) {
// Use of the ClassTimer function -> see ClassTimer for documentation
// Use of the ClassTimer function -> see ClassTimer for documentation
auto tc = corsika::analytics::ClassTimer<
EProcessReturn (detail::ExecTimeImpl<T>::_T::*)(Particle&, VTNType const&,
VTNType const&),
&detail::ExecTimeImpl<T>::_T::template DoBoundaryCrossing<Particle, VTNType>>(*this);
VTNType const&),
&detail::ExecTimeImpl<T>::_T::template DoBoundaryCrossing<Particle, VTNType>>(
*this);
EProcessReturn r = tc.call(p, from, to);
this->update(
......
......@@ -18,9 +18,9 @@
#include <corsika/process/example_processors/DummyInteractionProcess.h>
#include <corsika/process/example_processors/DummySecondariesProcess.h>
#include <cmath>
#include <random>
#include <vector>
#include <cmath>
using namespace corsika::process;
using namespace corsika::process::analytic_processors;
......
......@@ -21,13 +21,12 @@ namespace corsika::process {
: public BoundaryCrossingProcess<DummyBoundaryCrossingProcess<ISleep>> {
private:
protected:
public:
template <typename Particle, typename VTNType>
EProcessReturn DoBoundaryCrossing(Particle&, VTNType const&, VTNType const&) {
std::this_thread::sleep_for(std::chrono::milliseconds(ISleep));
return EProcessReturn::eOk;
}
}
};
} // namespace example_processors
......
......@@ -17,7 +17,8 @@ namespace corsika::process {
namespace example_processors {
template <int ISleep>
class DummyInteractionProcess : public InteractionProcess<DummyInteractionProcess<ISleep> > {
class DummyInteractionProcess
: public InteractionProcess<DummyInteractionProcess<ISleep> > {
private:
public:
template <typename Particle>
......
......@@ -17,7 +17,8 @@ namespace corsika::process {
namespace example_processors {
template <int ISleep>
class DummySecondariesProcess : public SecondariesProcess<DummySecondariesProcess<ISleep>> {
class DummySecondariesProcess
: public SecondariesProcess<DummySecondariesProcess<ISleep>> {
private:
public:
template <typename TSecondaries>
......
......@@ -48,13 +48,14 @@ TEST_CASE("Dummy Processes") {
Approx(1000).margin(1));
start = std::chrono::steady_clock::now();
REQUIRE(dc.MaxStepLength(nullptr, nullptr) == units::si::meter * std::numeric_limits<double>::infinity());
REQUIRE(dc.MaxStepLength(nullptr, nullptr) ==
units::si::meter * std::numeric_limits<double>::infinity());
end = std::chrono::steady_clock::now();
REQUIRE(std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() ==
Approx(1000).margin(1));
}
SECTION("Decay") {
SECTION("Decay") {
auto start = std::chrono::steady_clock::now();
REQUIRE(dd.DoDecay(tmp) == EProcessReturn::eOk);
auto end = std::chrono::steady_clock::now();
......@@ -62,13 +63,14 @@ TEST_CASE("Dummy Processes") {
Approx(1000).margin(1));
start = std::chrono::steady_clock::now();
REQUIRE(dd.GetLifetime(tmp) == units::si::second * std::numeric_limits<double>::infinity());
REQUIRE(dd.GetLifetime(tmp) ==
units::si::second * std::numeric_limits<double>::infinity());
end = std::chrono::steady_clock::now();
REQUIRE(std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() ==
Approx(1000).margin(1));
}
SECTION("Interaction") {
SECTION("Interaction") {
auto start = std::chrono::steady_clock::now();
REQUIRE(di.DoInteraction(tmp) == EProcessReturn::eOk);
auto end = std::chrono::steady_clock::now();
......@@ -76,18 +78,18 @@ TEST_CASE("Dummy Processes") {
Approx(1000).margin(1));
start = std::chrono::steady_clock::now();
REQUIRE(di.GetInteractionLength(tmp) == (units::si::gram / 1_cm / 1_cm) * std::numeric_limits<double>::infinity());
REQUIRE(di.GetInteractionLength(tmp) ==
(units::si::gram / 1_cm / 1_cm) * std::numeric_limits<double>::infinity());
end = std::chrono::steady_clock::now();
REQUIRE(std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() ==
Approx(1000).margin(1));
}
SECTION("Secondaries") {
SECTION("Secondaries") {
auto start = std::chrono::steady_clock::now();
REQUIRE(dse.DoSecondaries(tmp) == EProcessReturn::eOk);
auto end = std::chrono::steady_clock::now();
REQUIRE(std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() ==
Approx(1000).margin(1));
}
}
......@@ -23,9 +23,9 @@ namespace corsika::process::longitudinal_profile {
/**
* \class LongitudinalProfile
*
* is a ContinuousProcess, which is constructed from an environment::ShowerAxis
* is a ContinuousProcess, which is constructed from an environment::ShowerAxis
* object, and a dX in units of g/cm2
* (corsika::units::si::GrammageType).
* (corsika::units::si::GrammageType).
*
* LongitudinalProfile does then convert each single Track of the
* simulation into a projected grammage range and counts for
......
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