gwnavgeneration/generator/generatorprofiling.h Source File

generatorprofiling.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 
9 // primary contact: GUAL - secondary contact: NOBODY
10 #ifndef GwNavGen_GeneratorProfiling_H
11 #define GwNavGen_GeneratorProfiling_H
12 
13 
17 
18 
19 
20 namespace Kaim
21 {
22 
23 
24 class CellProfiling
25 {
26  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
27 public:
28  CellProfiling() : m_totalMs(0.0f) {}
29 
30  void Integrate(KyFloat32 milliseconds, const CellPos& cellPos)
31  {
32  m_totalMs += milliseconds;
33 
34  if (milliseconds > m_maxMs)
35  {
36  m_maxMs = milliseconds;
37  m_maxCellPos = cellPos;
38  }
39  }
40 
41 public:
42  KyFloat32 m_totalMs;
43  KyFloat32 m_maxMs;
44  CellPos m_maxCellPos;
45 };
46 
47 
48 template <class OSTREAM>
49 inline OSTREAM& operator<<(OSTREAM& os, const Kaim::CellProfiling& c)
50 {
51  os << " total(s)=" << c.m_totalMs * 0.001f << " max(ms)=" << c.m_maxMs << " @ " << c.m_maxCellPos;
52  return os;
53 }
54 
55 
56 class GeneratorProfiling
57 {
58  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
59 
60 public:
61  GeneratorProfiling() {}
62 
63  void Integrate(const CellGeneratorProfiling& cellProfiling, const CellPos& cellPos)
64  {
65  m_raster.Integrate( cellProfiling.m_rasterMs , cellPos);
66  m_navRaster.Integrate( cellProfiling.m_navRasterMs , cellPos);
67  m_navRasterPainting.Integrate(cellProfiling.m_navRasterPaintingMs, cellPos);
68  m_heightField.Integrate( cellProfiling.m_heightFieldMs , cellPos);
69  m_boundaries.Integrate( cellProfiling.m_boundariesMs , cellPos);
70  m_navCell.Integrate( cellProfiling.m_navCellMs , cellPos);
71  }
72 
73 public:
74  CellProfiling m_raster;
75  CellProfiling m_navRaster;
76  CellProfiling m_navRasterPainting;
77  CellProfiling m_heightField;
78  CellProfiling m_boundaries;
79  CellProfiling m_navCell;
80 };
81 
82 
83 template<class OSTREAM>
84 inline OSTREAM& operator<<(OSTREAM& os, const GeneratorProfiling& profiling)
85 {
86  os << KY_LOG_SMALL_TITLE_BEGIN("", "Generator Profiling");
87  os << "raster " << profiling.m_raster << Endl;
88  os << "navRaster " << profiling.m_navRaster << Endl;
89  os << "navRasterPainting " << profiling.m_navRasterPainting << Endl;
90  os << "heightField " << profiling.m_heightField << Endl;
91  os << "boundaries " << profiling.m_boundaries << Endl;
92  os << "navCellBlob " << profiling.m_navCell << Endl;
93  os << KY_LOG_SMALL_TITLE_END("", "Generator Profiling");
94  return os;
95 }
96 
97 
98 }
99 
100 
101 #endif
102 
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:33
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43