AGX Dynamics  2.35.0.1
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 
38  AGXTERRAIN_EXPORT void printToFile(agx::Real time, const agx::String& filename);
39  AGXTERRAIN_EXPORT void resetFile(const agx::String& filename);
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 
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXTERRAIN_EXPORT
ScopeTimer(const agx::Name &name)
agx::HighAccuracyTimer m_timer
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: HashVector.h:41
The HighAccurayTimer class can replace the regular Timer class in high level applications where the n...
Representation of a name string.
Definition: Name.h:33
Base class providing referencing counted objects.
Definition: Referenced.h:114
AGXTERRAIN_EXPORT agx::Real & currentTime()
AGXTERRAIN_EXPORT void resetFile(const agx::String &filename)
AGXTERRAIN_EXPORT void registerTiming(const agx::Name &name, agx::Real value)
AGXTERRAIN_EXPORT void printTimers(const agx::String &title)
agx::HashVector< agx::Name, agx::Real > TimingStorage
std::pair< agx::Name, agx::Real > Bucket
AGXTERRAIN_EXPORT void clear()
AGXTERRAIN_EXPORT void printToFile(agx::Real time, const agx::String &filename)
AGXTERRAIN_EXPORT TimingStorage & getStorage()
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:60
double Real
Definition: Real.h:42