Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_TimeMeasurementHelper.c
Go to the documentation of this file.
1 class SCR_TimeMeasurementHelper
26 {
27  protected ref map<string, ref SCR_TimeMeasurementHelper_Info> m_mData;
28 
29  //------------------------------------------------------------------------------------------------
32  void BeginMeasure(string name)
33  {
34  SCR_TimeMeasurementHelper_Info info = m_mData.Get(name);
35  if (!info)
36  {
37  info = new SCR_TimeMeasurementHelper_Info();
38  m_mData.Insert(name, info);
39  }
40 
41  info.m_fStart = System.GetTickCount();
42  }
43 
44  //------------------------------------------------------------------------------------------------
48  void EndMeasure(string name)
49  {
50  SCR_TimeMeasurementHelper_Info info = m_mData.Get(name);
51  if (!info)
52  {
53  Print("No measurement named \"" + name + "\" was found", LogLevel.WARNING);
54  return;
55  }
56 
57  info.m_fTotal += System.GetTickCount(info.m_fStart);
58  }
59 
60  //------------------------------------------------------------------------------------------------
65  float GetMeasure(string name)
66  {
67  SCR_TimeMeasurementHelper_Info info = m_mData.Get(name);
68  if (!info)
69  {
70  Print("No measurement named \"" + name + "\" was found", LogLevel.WARNING);
71  return -1;
72  }
73 
74  return info.m_fTotal;
75  }
76 
77  //------------------------------------------------------------------------------------------------
79  void PrintAllMeasures()
80  {
81  foreach (string name, SCR_TimeMeasurementHelper_Info info : m_mData)
82  {
83  Print("Measure \"" + name + "\": " + info.m_fTotal + " ms", LogLevel.NORMAL);
84  }
85  }
86 
87  //------------------------------------------------------------------------------------------------
89  void Reset()
90  {
91  m_mData.Clear();
92  }
93 
94  //------------------------------------------------------------------------------------------------
95  // constructor
96  void SCR_TimeMeasurementHelper()
97  {
98  m_mData = new map<string, ref SCR_TimeMeasurementHelper_Info>();
99  }
100 }
101 
102 // databag
103 class SCR_TimeMeasurementHelper_Info
104 {
105  float m_fStart;
106  float m_fTotal;
107 }
Reset
void Reset()
Sets variables to default values when freed to be reused by another object on demand.
Definition: SCR_BuildingDestructionManagerComponent.c:34