AGXDynamics  2.35.0.2
ProfilingTools.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agxTerrain/export.h>
20 #include <agx/Referenced.h>
21 #include <agx/Name.h>
22 #include <agx/HighAccuracyTimer.h>
23 #include <agx/HashTable.h>
24 #include <agx/HashVector.h>
25 #include <iostream>
26 #include <iomanip>
27 
28 namespace agxTerrain
29 {
30  namespace Profiler
31  {
33  using Bucket = std::pair<agx::Name, agx::Real>;
34 
36  AGXTERRAIN_EXPORT void clear();
37  AGXTERRAIN_EXPORT void printTimers(const agx::String& title);
38  AGXTERRAIN_EXPORT void printToFile(agx::Real time, const agx::String& filename);
39  AGXTERRAIN_EXPORT void resetFile(const agx::String& filename);
40  AGXTERRAIN_EXPORT void registerTiming(const agx::Name& name, agx::Real value);
42  }
43 
46  {
47  public:
48  explicit ScopeTimer(const agx::Name& name)
49  : m_timer(false)
50  , m_name(name)
51  {
52  m_timer.start();
53  }
54 
55  protected:
56  virtual ~ScopeTimer()
57  {
58  m_timer.stop();
59  Profiler::registerTiming(m_name, m_timer.getTime());
60  }
61 
64  };
65 }
66 
67 #define SCOPE_PROFILER(a) agxTerrain::ScopeTimerRef ref = new agxTerrain::ScopeTimer(a);
68 #define PRINT_TIMINGS() Profiler::printTimers();
69 
70 
71 #if defined(USE_EXTENDED_TERRAIN_PROFILING) && USE_EXTENDED_TERRAIN_PROFILING
72  #define GET_TIMESTAMP(varname) agx::UInt64 varname = agx::Timer::getCurrentTick();
73  #define THREAD_LOG_ITEM( textname, var1, var2 ) agx::Thread::getCurrentThread()->reportSystemJob( var1, var2, textname );
74 #else
75  #define GET_TIMESTAMP(varname)
76  #define THREAD_LOG_ITEM( textname, var1, var2 )
77 #endif
78 
79 
Referenced.h
agxTerrain::ScopeTimer::m_name
agx::Name m_name
Definition: ProfilingTools.h:63
agxTerrain::Profiler::Bucket
std::pair< agx::Name, agx::Real > Bucket
Definition: ProfilingTools.h:33
agx::Real
double Real
Definition: Real.h:42
agxTerrain
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:59
agxTerrain::ScopeTimer::~ScopeTimer
virtual ~ScopeTimer()
Definition: ProfilingTools.h:56
HashTable.h
HashVector.h
agxTerrain::ScopeTimer
Definition: ProfilingTools.h:45
Name.h
export.h
agxTerrain::ScopeTimer::ScopeTimer
ScopeTimer(const agx::Name &name)
Definition: ProfilingTools.h:48
agxTerrain::Profiler::resetFile
AGXTERRAIN_EXPORT void resetFile(const agx::String &filename)
agx::HighAccuracyTimer
The HighAccurayTimer class can replace the regular Timer class in high level applications where the n...
Definition: HighAccuracyTimer.h:63
agxTerrain::Profiler::getStorage
AGXTERRAIN_EXPORT TimingStorage & getStorage()
agxTerrain::Profiler::currentTime
AGXTERRAIN_EXPORT agx::Real & currentTime()
agxTerrain::Profiler::printTimers
AGXTERRAIN_EXPORT void printTimers(const agx::String &title)
agx::Name
Representation of a name string.
Definition: Name.h:32
agxTerrain::Profiler::registerTiming
AGXTERRAIN_EXPORT void registerTiming(const agx::Name &name, agx::Real value)
agxTerrain::ScopeTimer::m_timer
agx::HighAccuracyTimer m_timer
Definition: ProfilingTools.h:62
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
AGXTERRAIN_EXPORT
#define AGXTERRAIN_EXPORT
Definition: agxTerrain/export.h:41
agxTerrain::Profiler::printToFile
AGXTERRAIN_EXPORT void printToFile(agx::Real time, const agx::String &filename)
agx::AgXString< std::string >
agxTerrain::Profiler::TimingStorage
agx::HashVector< agx::Name, agx::Real > TimingStorage
Definition: ProfilingTools.h:32
agxTerrain::Profiler::clear
AGXTERRAIN_EXPORT void clear()
HighAccuracyTimer.h
agx::HashVector
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: HashVector.h:40