DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ TestFuncTimeData()

TFResult EnProfilerTests::TestFuncTimeData ( )
inlineprivate

См. определение в файле EnProfilerTests.c строка 481

482 {
483 // We should restore this when done
484 int resolution = EnProfiler.GetTimeResolution();
485 bool wasEnabled = EnProfiler.RequestImmediateData();
486
487 // GetTickTime() returns in seconds, so gather the results in seconds too
488 EnProfiler.SetTimeResolution(1);
489
490 // Time to stress
491 float previousTime = EnProfiler.GetTimeOfFunc("StringFormat", Type(), true);
492 float timeStressed = StringFormat();
493 float postTime = EnProfiler.GetTimeOfFunc("StringFormat", Type(), true);
494 float timeProfiled = postTime - previousTime;
495 float diff = Math.AbsFloat(timeProfiled - timeStressed);
496
497 float previousTime2 = EnProfiler.GetTimeOfFunc("StringConcat", Type(), true);
498 float timeStressed2 = StringConcat();
499 float postTime2 = EnProfiler.GetTimeOfFunc("StringConcat", Type(), true);
500 float timeProfiled2 = postTime2 - previousTime2;
501 float diff2 = Math.AbsFloat(timeProfiled2 - timeStressed2);
502
503 Debug.TFLog(string.Format("Profiling result: StringFormat: %1 | StringConcat: %2", timeProfiled, timeProfiled2), this, "TestFuncTimeData");
504
505 // Restore
506 EnProfiler.SetTimeResolution(resolution);
507 if (!wasEnabled)
508 {
509 EnProfiler.Enable(false, true);
510 }
511
512 // We called the function, so it must have some time
513 if (!Assert(postTime > 0))
514 {
515 return NTFR(TFR.FAIL);
516 }
517
518 if (!Assert(diff < 0.001))
519 {
520 return NTFR(TFR.FAIL);
521 }
522
523 if (!Assert(postTime2 > 0))
524 {
525 return NTFR(TFR.FAIL);
526 }
527
528 if (!Assert(diff2 < 0.001))
529 {
530 return NTFR(TFR.FAIL);
531 }
532
533 // I know that string.Format is faster than additive concatenation
534 if (!Assert(timeProfiled < timeProfiled2))
535 {
536 return NTFR(TFR.FAIL);
537 }
538
539 return NTFR(TFR.SUCCESS);
540 }
string Type
Определения JsonDataContaminatedArea.c:11
TFResult NTFR(TFR result)
Определения TestFramework.c:273
bool Assert(bool condition)
Определения TestFramework.c:262
TFR
Определения TestFramework.c:2
void Debug()
Определения UniversalTemperatureSource.c:349
float StringFormat()
Определения EnProfilerTests.c:720
float StringConcat()
Определения EnProfilerTests.c:734

Перекрестные ссылки Math::AbsFloat(), Assert(), EnProfiler::Enable(), EnProfiler::GetTimeOfFunc(), EnProfiler::GetTimeResolution(), NTFR(), EnProfiler::RequestImmediateData(), EnProfiler::SetTimeResolution(), StringConcat(), StringFormat(), Debug::TFLog(), TFResult() и Type.