190 {
191
193
194
195 string nameOfCurrentModule =
Type().GetModule();
196 if (!
Assert(nameOfCurrentModule !=
""))
197 {
199 }
200
201
203 if (!
Assert(EnProfiler.NameToModule(nameOfCurrentModule, currentModule)))
204 {
206 }
207
208 if (!
Assert(currentModule == eptModule))
209 {
211 }
212
213
215 EnProfiler.SetModule(eptModule);
216
217 if (!
Assert(EnProfiler.GetModule() == eptModule))
218 {
219 EnProfiler.SetModule(currentlyProfiledModule);
221 }
222
223
224 int currentFlags = EnProfiler.GetFlags();
225 bool wasEnabled = EnProfiler.RequestImmediateData();
226
227
228
230
231
232 int resolution = EnProfiler.GetTimeResolution();
233 EnProfiler.SetTimeResolution(1);
234
235
236 float previousTime = EnProfiler.GetTimeOfFunc(
"Sleep",
Type(),
true);
237 float timeSlept =
Sleep(0.3);
238 float postTime = EnProfiler.GetTimeOfFunc(
"Sleep",
Type(),
true);
239 float diff = postTime - previousTime - timeSlept;
240
241
242 EnProfiler.SetTimeResolution(resolution);
243
244
245 if (!
Assert(postTime > 0))
246 {
247 EnProfiler.SetFlags(currentFlags);
248
249 if (!wasEnabled)
250 EnProfiler.Enable(false, true);
251
252 EnProfiler.SetModule(currentlyProfiledModule);
253
255 }
256
257 if (!
Assert(diff < 0.00001))
258 {
259 EnProfiler.SetFlags(currentFlags);
260
261 if (!wasEnabled)
262 EnProfiler.Enable(false, true);
263
264 EnProfiler.SetModule(currentlyProfiledModule);
265
267 }
268
269
270 EnProfiler.ResetSession(true);
271
272
273 for (int i = 0; i < 1000; ++i)
274 {
276 }
277
278
279 EnProfiler.SortData();
280 array<ref EnProfilerTimeFuncPair> timePerFunc = {};
281 EnProfiler.GetTimePerFunc(timePerFunc);
282
283 Debug.TFLog(
"Game fncs:",
this,
"TestModule");
284
285 int funcCount = timePerFunc.Count();
286 for (int j = 0; j < funcCount; ++j)
287 {
289 Debug.TFLog(
string.Format(
" time: %1 | fnc: %2", tfp.param1, tfp.param2),
this,
"TestModule");
290
291 if (!
Assert(tfp.param2 !=
"EnumTools::StringToEnum"))
292 {
293 EnProfiler.SetFlags(currentFlags);
294
295 if (!wasEnabled)
296 EnProfiler.Enable(false, true);
297
298 EnProfiler.SetModule(currentlyProfiledModule);
299
301 }
302 }
303
304 array<ref EnProfilerTimeClassPair> timePerClass = {};
305 EnProfiler.GetTimePerClass(timePerClass);
306
307 int classCount = timePerClass.Count();
308 for (int k = 0; k < classCount; ++k)
309 {
310 typename type = timePerClass[k].param2;
312 if (!
Assert(EnProfiler.NameToModule(type.GetModule(), classModule)))
313 {
314 EnProfiler.SetFlags(currentFlags);
315
316 if (!wasEnabled)
317 EnProfiler.Enable(false, true);
318
319 EnProfiler.SetModule(currentlyProfiledModule);
320
322 }
323
324
325 if (!
Assert(classModule == eptModule))
326 {
327 EnProfiler.SetFlags(currentFlags);
328
329 if (!wasEnabled)
330 EnProfiler.Enable(false, true);
331
332 EnProfiler.SetModule(currentlyProfiledModule);
333
335 }
336 }
337
338
340 EnProfiler.SortData();
341 timePerFunc.Clear();
342 EnProfiler.GetTimePerFunc(timePerFunc);
343
344 bool found = false;
345
346 Debug.TFLog(
"Core fncs:",
this,
"TestModule");
347
348 funcCount = timePerFunc.Count();
349 for (int l = 0; l < funcCount; ++l)
350 {
352 Debug.TFLog(
string.Format(
" time: %1 | fnc: %2", tfpc.param1, tfpc.param2),
this,
"TestModule");
353
354 if (tfpc.param2 == "EnumTools::StringToEnum")
355 {
356 found = true;
357 break;
358 }
359 }
360
362
363
365 EnProfiler.SetModule(-333);
366 bool success =
Assert(EnProfiler.GetModule() == mod);
367 EnProfiler.SetModule(6003);
368 success &=
Assert(EnProfiler.GetModule() == mod);
369
370 EnProfiler.SetFlags(currentFlags);
371 EnProfiler.SetModule(currentlyProfiledModule);
372
373 if (!wasEnabled)
374 EnProfiler.Enable(false, true);
375
376 return BTFR(success && found);
377 }
TFResult NTFR(TFR result)
bool Assert(bool condition)
TFResult BTFR(bool result)
Param2< float, string > EnProfilerTimeFuncPair
EnProfilerFlags
Flags that influences the behaviour of the EnProfiler API, applied through ...Flags functions.
EnProfilerModule
Current base scripted modules.