gwnavgeneration/generator/generatorprofiling.h Source File

generatorprofiling.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
10 
11 
15 
16 
17 
18 namespace Kaim
19 {
20 
21 
22 class CellProfiling
23 {
24  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
25 public:
26  CellProfiling() : m_totalMs(0.0f) {}
27 
28  void Integrate(KyFloat32 milliseconds, const CellPos& cellPos)
29  {
30  m_totalMs += milliseconds;
31 
32  if (milliseconds > m_maxMs)
33  {
34  m_maxMs = milliseconds;
35  m_maxCellPos = cellPos;
36  }
37  }
38 
39 public:
40  KyFloat32 m_totalMs;
41  KyFloat32 m_maxMs;
42  CellPos m_maxCellPos;
43 };
44 
45 
46 template <class OSTREAM>
47 inline OSTREAM& operator<<(OSTREAM& os, const Kaim::CellProfiling& c)
48 {
49  os << " total(s)=" << c.m_totalMs * 0.001f << " max(ms)=" << c.m_maxMs << " @ " << c.m_maxCellPos;
50  return os;
51 }
52 
53 
54 class GeneratorProfiling
55 {
56  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
57 
58 public:
59  GeneratorProfiling() {}
60 
61  void Integrate(const CellGeneratorProfiling& cellProfiling, const CellPos& cellPos)
62  {
63  m_raster.Integrate( cellProfiling.m_rasterMs , cellPos);
64  m_navRaster.Integrate( cellProfiling.m_navRasterMs , cellPos);
65  m_navRasterPainting.Integrate(cellProfiling.m_navRasterPaintingMs, cellPos);
66  m_heightField.Integrate( cellProfiling.m_heightFieldMs , cellPos);
67  m_boundaries.Integrate( cellProfiling.m_boundariesMs , cellPos);
68  m_navCell.Integrate( cellProfiling.m_navCellMs , cellPos);
69  }
70 
71 public:
72  CellProfiling m_raster;
73  CellProfiling m_navRaster;
74  CellProfiling m_navRasterPainting;
75  CellProfiling m_heightField;
76  CellProfiling m_boundaries;
77  CellProfiling m_navCell;
78 };
79 
80 
81 template<class OSTREAM>
82 inline OSTREAM& operator<<(OSTREAM& os, const GeneratorProfiling& profiling)
83 {
84  os << KY_LOG_SMALL_TITLE_BEGIN("", "Generator Profiling");
85  os << "raster " << profiling.m_raster << Endl;
86  os << "navRaster " << profiling.m_navRaster << Endl;
87  os << "navRasterPainting " << profiling.m_navRasterPainting << Endl;
88  os << "heightField " << profiling.m_heightField << Endl;
89  os << "boundaries " << profiling.m_boundaries << Endl;
90  os << "navCellBlob " << profiling.m_navCell << Endl;
91  os << KY_LOG_SMALL_TITLE_END("", "Generator Profiling");
92  return os;
93 }
94 
95 
96 }
97 
98 
99 
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:30
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
float KyFloat32
float
Definition: types.h:32