MCPcopy Create free account
hub / github.com/REGoth-project/REGoth / onFrameEnd

Method onFrameEnd

src/logic/ScriptEngine.cpp:432–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432void ScriptEngine::onFrameEnd()
433{
434#if PROFILE_SCRIPT_CALLS
435 // Get the 5 most costly calls
436 std::vector<std::pair<size_t, double>> calls;
437 std::map<size_t, double> combined;
438
439 volatile double sum = 0.0;
440 for (int i = 0; i < 10; i++)
441 {
442 for (auto& p : m_TimeByFunctionSymbol[i])
443 {
444 if (combined.find(p.first) == combined.end())
445 combined[p.first] = 0;
446
447 combined[p.first] += p.second / 10;
448 }
449 }
450
451 for (auto& p : combined)
452 {
453 sum += p.second;
454 calls.push_back(p);
455 }
456
457 // Sort descending
458 std::sort(calls.begin(), calls.end(), [](const std::pair<size_t, double>& a, const std::pair<size_t, double>& b) {
459 return a.second > b.second;
460 });
461
462 bgfx::dbgTextPrintf(60, 0, 0x0f, "Script profiling [ms] (Total: %.3f):", sum * 1000.0);
463 for (int i = 0; i < std::min(5, (int)calls.size()); i++)
464 {
465 std::string name = getVM().getDATFile().getSymbolByIndex(calls[i].first).name;
466 bgfx::dbgTextPrintf(60, 1 + i, 0x0f, " %s: %.3f", name.c_str(), calls[i].second * 1000.0);
467 }
468#endif
469}
470
471void ScriptEngine::exportScriptEngine(json& j)
472{

Callers 1

onFrameUpdateMethod · 0.80

Calls 5

findMethod · 0.80
push_backMethod · 0.80
endMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected