profile.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef _SCTL_PROFILE_HPP_
  2. #define _SCTL_PROFILE_HPP_
  3. #include <sctl/common.hpp>
  4. #include <string>
  5. #include <vector>
  6. #include <stack>
  7. #ifndef SCTL_PROFILE
  8. #define SCTL_PROFILE -1
  9. #endif
  10. namespace SCTL_NAMESPACE {
  11. class Comm;
  12. class Profile {
  13. public:
  14. static Long Add_MEM(Long inc);
  15. static Long Add_FLOP(Long inc);
  16. static bool Enable(bool state);
  17. static void Tic(const char* name_, const Comm* comm_ = nullptr, bool sync_ = false, Integer level = 0);
  18. static void Toc();
  19. static void print(const Comm* comm_ = nullptr);
  20. static void reset();
  21. private:
  22. struct ProfileData {
  23. Long MEM;
  24. Long FLOP;
  25. bool enable_state;
  26. std::stack<bool> sync;
  27. std::stack<std::string> name;
  28. std::stack<const Comm*> comm;
  29. std::vector<Long> max_mem;
  30. Integer enable_depth;
  31. std::stack<int> verb_level;
  32. std::vector<bool> e_log;
  33. std::vector<bool> s_log;
  34. std::vector<std::string> n_log;
  35. std::vector<double> t_log;
  36. std::vector<Long> f_log;
  37. std::vector<Long> m_log;
  38. std::vector<Long> max_m_log;
  39. ProfileData() : MEM(0), FLOP(0), enable_state(false), enable_depth(0) {}
  40. };
  41. static inline ProfileData& ProfData() {
  42. static ProfileData p;
  43. return p;
  44. }
  45. };
  46. } // end namespace
  47. #include SCTL_INCLUDE(profile.txx)
  48. #endif //_SCTL_PROFILE_HPP_