diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 575b4e6b6e..669a374d6e 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -5,6 +5,7 @@ - Improved: [#25526] When a shop item cannot be recoloured, show a preview of the building instead. - Improved: [#25941] The command line sprite build command is now faster. - Improved: [#26002] Rides with newer track elements (like the zero G roll or diagonal brakes) can now be saved as track designs. +- Improved: [#26026] Profiler is now thread safe and supports JSON export with call graph data. - Improved: [#26050] Add Danish translation to Windows installer. - Improved: [#26091] When all rides are closed, the marketing window will no longer show the ride advertisement campaign. - Change: [#26011] Audio resampling no longer depends on the third-party library libspeexdsp. diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index ce22df39d3..c932d652e5 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1687,42 +1687,71 @@ static void ConsoleCommandAddNewsItem([[maybe_unused]] InteractiveConsole& conso static void ConsoleCommandProfilerReset([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) { - Profiling::ResetData(); -} -static void ConsoleCommandProfilerStart([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) -{ - if (!Profiling::IsEnabled()) - console.WriteLine("Started profiler"); - Profiling::Enable(); + Profiling::resetData(); + console.WriteLine("Profiler data reset"); } -static void ConsoleCommandProfilerExportCSV( - [[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) +static void ConsoleCommandProfilerStatus([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) +{ + const auto& data = Profiling::getData(); + console.WriteFormatLine("Profiler status: %s", Profiling::isEnabled() ? "ENABLED" : "DISABLED"); + console.WriteFormatLine("Registered functions: %zu", data.size()); + + if (!data.empty()) + { + uint64_t totalCalls = 0; + double totalTimeUs = 0.0; + size_t functionsWithData = 0; + + for (const auto& f : data) + { + auto calls = f->getCallCount(); + totalCalls += calls; + totalTimeUs += f->getTotalTime(); + if (calls > 0) + functionsWithData++; + } + + console.WriteFormatLine("Functions with data: %zu / %zu", functionsWithData, data.size()); + console.WriteFormatLine("Total recorded calls: %llu", static_cast(totalCalls)); + console.WriteFormatLine("Total recorded time: %.3f ms", totalTimeUs / 1000.0); + } +} + +static void ConsoleCommandProfilerStart([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) +{ + if (!Profiling::isEnabled()) + console.WriteLine("Started profiler"); + Profiling::enable(); +} + +static void ConsoleCommandProfilerExport([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) { if (argv.empty()) { console.WriteLineError("Missing argument: "); + return; } - const auto& csvFilePath = argv[0]; - if (!Profiling::ExportCSV(csvFilePath)) + const auto& filePath = argv[0]; + if (!Profiling::exportData(filePath)) { - console.WriteFormatLine("Unable to export CSV file to %s", csvFilePath.c_str()); + console.WriteFormatLine("Unable to export profiler data to %s", filePath.c_str()); + return; } - console.WriteFormatLine("Wrote file CSV file: \"%s\"", csvFilePath.c_str()); + console.WriteFormatLine("Wrote profiler data: \"%s\"", filePath.c_str()); } static void ConsoleCommandProfilerStop([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) { - if (Profiling::IsEnabled()) + if (Profiling::isEnabled()) console.WriteLine("Stopped profiler"); - Profiling::Disable(); + Profiling::disable(); - // Export to CSV if argument is provided. if (!argv.empty()) { - return ConsoleCommandProfilerExportCSV(console, argv); + return ConsoleCommandProfilerExport(console, argv); } } @@ -1849,9 +1878,11 @@ static constexpr ConsoleCommand console_command_table[] = { "ConsoleCommandMpDesync [desync_type, 0 = Random t-shirt color on random guest, 1 = Remove random guest ]" }, { "profiler_reset", ConsoleCommandProfilerReset, "Resets the profiler data.", "profiler_reset" }, { "profiler_start", ConsoleCommandProfilerStart, "Starts the profiler.", "profiler_start" }, - { "profiler_stop", ConsoleCommandProfilerStop, "Stops the profiler.", "profiler_stop []" }, - { "profiler_exportcsv", ConsoleCommandProfilerExportCSV, "Exports the current profiler data.", - "profiler_exportcsv " }, + { "profiler_status", ConsoleCommandProfilerStatus, "Shows profiler status and statistics.", "profiler_status" }, + { "profiler_stop", ConsoleCommandProfilerStop, "Stops the profiler and optionally exports data.", + "profiler_stop []" }, + { "profiler_export", ConsoleCommandProfilerExport, "Exports profiler data (format from extension, default CSV).", + "profiler_export " }, }; static void ConsoleCommandWindows(InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) diff --git a/src/openrct2/profiling/Profiling.cpp b/src/openrct2/profiling/Profiling.cpp index 6f8591a7a7..82bcdce432 100644 --- a/src/openrct2/profiling/Profiling.cpp +++ b/src/openrct2/profiling/Profiling.cpp @@ -9,166 +9,290 @@ #include "Profiling.h" +#include "../core/Json.hpp" + +#include #include +#include #include #include #include -#include namespace OpenRCT2::Profiling { - inline static bool _enabled = false; + // Global enable flag, atomic for thread safety + static std::atomic _enabled{ false }; - void Enable() + void enable() { - _enabled = true; + _enabled.store(true, std::memory_order_release); } - void Disable() + void disable() { - _enabled = false; + _enabled.store(false, std::memory_order_release); } - bool IsEnabled() + bool isEnabled() { - return _enabled; + return _enabled.load(std::memory_order_acquire); } namespace Detail { using Clock = std::chrono::high_resolution_clock; - using Tp = Clock::time_point; + using TimePoint = Clock::time_point; - struct FunctionEntry + struct StackEntry { FunctionInternal* Parent; FunctionInternal* Func; - Tp EntryTime; - - FunctionEntry(FunctionInternal* parent, FunctionInternal* func, const Tp& entryTime) - : Parent(parent) - , Func(func) - , EntryTime(entryTime) - { - } + TimePoint EntryTime; }; - static thread_local std::stack _callStack; + static thread_local std::vector _callStack; + static std::vector _registry; + static std::mutex _registryMutex; - void FunctionEnter(Function& func) + std::vector& getRegistry() { - const auto entryTime = Clock::now(); - - auto& funcInternal = static_cast(func); - funcInternal.CallCount++; - - FunctionInternal* parent = nullptr; - - if (!_callStack.empty()) - parent = _callStack.top().Func; - - _callStack.emplace(parent, &funcInternal, entryTime); + return _registry; } - void FunctionExit(Function& func) + std::mutex& getRegistryMutex() + { + return _registryMutex; + } + + void registerFunction(FunctionInternal* func) + { + std::scoped_lock lock(_registryMutex); + _registry.push_back(func); + } + + void functionEnter(FunctionInternal& func) + { + const auto entryTime = Clock::now(); + func.CallCount.fetch_add(1, std::memory_order_relaxed); + + FunctionInternal* parent = nullptr; + if (!_callStack.empty()) + { + parent = _callStack.back().Func; + } + + _callStack.push_back({ parent, &func, entryTime }); + } + + bool FunctionInternal::tryAddParent(FunctionInternal* parent) + { + std::scoped_lock lock(Mutex); + if (std::find(Parents.begin(), Parents.end(), parent) == Parents.end()) + { + Parents.push_back(parent); + return true; + } + return false; + } + + bool FunctionInternal::tryAddChild(FunctionInternal* child) + { + std::scoped_lock lock(Mutex); + if (std::find(Children.begin(), Children.end(), child) == Children.end()) + { + Children.push_back(child); + return true; + } + return false; + } + + std::vector FunctionInternal::getTimeSamples() const + { + const size_t totalSamples = SampleIndex.load(std::memory_order_relaxed); + const size_t count = std::min(totalSamples, MaxSamplesSize); + std::vector result; + result.reserve(count); + + const size_t startIdx = (totalSamples > MaxSamplesSize) ? (totalSamples % MaxSamplesSize) : 0; + for (size_t i = 0; i < count; ++i) + { + const size_t idx = (startIdx + i) % MaxSamplesSize; + result.push_back(static_cast(Samples[idx].load(std::memory_order_relaxed)) / 1000.0); + } + return result; + } + + void functionExit(FunctionInternal& func) { const auto exitTime = Clock::now(); - assert(!_callStack.empty()); + assert(!_callStack.empty() && "FunctionExit called without matching FunctionEnter"); - auto& stackEntry = _callStack.top(); + const auto& entry = _callStack.back(); + assert(entry.Func == &func && "FunctionExit called for wrong function"); - const auto deltaTime = exitTime - stackEntry.EntryTime; + const auto elapsed = exitTime - entry.EntryTime; + const auto elapsedNs = static_cast(std::chrono::duration_cast(elapsed).count()); - // Elapsed microseconds. - const auto elapsedTimeUs = std::chrono::duration_cast(deltaTime).count() / 1000.0; + // All timing updates are lock free + func.TotalTimeNs.fetch_add(elapsedNs, std::memory_order_relaxed); + func.updateMin(elapsedNs); + func.updateMax(elapsedNs); - auto* funcData = stackEntry.Func; + const size_t idx = func.SampleIndex.fetch_add(1, std::memory_order_relaxed) % MaxSamplesSize; + func.Samples[idx].store(elapsedNs, std::memory_order_relaxed); - // We don't need a lock for this, we only have a fixed window. - const auto sampleEntryIdx = funcData->SampleIterator++ % funcData->Samples.size(); - funcData->Samples[sampleEntryIdx] = elapsedTimeUs; - - if (stackEntry.Parent) + // Only take locks when discovering new relationships + if (entry.Parent != nullptr) { - std::scoped_lock lock(stackEntry.Parent->Mutex); - stackEntry.Parent->Children.insert(funcData); + // If this is the same parent as last time, skip lock + FunctionInternal* lastParent = func.LastParent.load(std::memory_order_relaxed); + if (lastParent != entry.Parent) + { + // Potentially new relationship so take locks and check + if (func.tryAddParent(entry.Parent)) + { + entry.Parent->tryAddChild(&func); + } + func.LastParent.store(entry.Parent, std::memory_order_relaxed); + } } - // This requires locking. - { - std::scoped_lock lock(funcData->Mutex); - - if (stackEntry.Parent) - funcData->Parents.insert(stackEntry.Parent); - - if (funcData->MinTimeUs == 0.0) - funcData->MinTimeUs = elapsedTimeUs; - else - funcData->MinTimeUs = std::min(elapsedTimeUs, funcData->MinTimeUs); - - funcData->MaxTimeUs = std::max(elapsedTimeUs, funcData->MaxTimeUs); - funcData->TotalTimeUs += elapsedTimeUs; - } - - _callStack.pop(); - } - - std::vector& GetRegistry() - { - static std::vector Registry; - return Registry; + _callStack.pop_back(); } } // namespace Detail - const std::vector& GetData() + const std::vector& getData() { - return Detail::GetRegistry(); + // eturns reference to static vector. Safe because functions are only registered during static initialization. + return Detail::getRegistry(); } - void ResetData() + void resetData() { - for (auto* func : Detail::GetRegistry()) - { - auto* funcInternal = static_cast(func); + std::scoped_lock lock(Detail::getRegistryMutex()); - std::scoped_lock lock(funcInternal->Mutex); - funcInternal->CallCount = 0; - funcInternal->MinTimeUs = 0.0; - funcInternal->MaxTimeUs = 0.0; - funcInternal->SampleIterator = 0; - funcInternal->Children.clear(); - funcInternal->Parents.clear(); + for (auto* func : Detail::getRegistry()) + { + auto* internal = static_cast(func); + + internal->CallCount.store(0, std::memory_order_relaxed); + internal->TotalTimeNs.store(0, std::memory_order_relaxed); + internal->MinTimeNs.store(0, std::memory_order_relaxed); + internal->MaxTimeNs.store(0, std::memory_order_relaxed); + internal->SampleIndex.store(0, std::memory_order_relaxed); + internal->LastParent.store(nullptr, std::memory_order_relaxed); + + for (auto& sample : internal->Samples) + { + sample.store(0, std::memory_order_relaxed); + } + + { + std::scoped_lock funcLock(internal->Mutex); + internal->Parents.clear(); + internal->Children.clear(); + } } } - bool ExportCSV(const std::string& filePath) + namespace { - std::ofstream out(filePath); - if (!out.is_open()) - return false; - - out << "function_name;calls;min_microseconds;max_microseconds;average_microseconds\n"; - out << std::setprecision(12); - - const auto& data = GetData(); - for (auto* func : data) + bool writeCSV(const std::string& filePath) { - out << "\"" << func->GetName() << "\"" - << ";"; - out << func->GetCallCount() << ";"; - out << func->GetMinTime() << ";"; - out << func->GetMaxTime() << ";"; + std::ofstream out(filePath); + if (!out.is_open()) + return false; - double avg = 0.0; - if (func->GetCallCount() > 0) - avg = func->getTotalTime() / func->GetCallCount(); + out << std::setprecision(12); + out << "function_name,calls,min_microseconds,max_microseconds,average_microseconds,total_microseconds\n"; - out << avg << "\n"; + std::scoped_lock lock(Detail::getRegistryMutex()); + + for (const auto* func : Detail::getRegistry()) + { + out << "\"" << func->getName() << "\","; + out << func->getCallCount() << ","; + out << func->getMinTime() << ","; + out << func->getMaxTime() << ","; + out << func->getAverageTime() << ","; + out << func->getTotalTime() << "\n"; + } + + return true; } - return true; + bool writeJSON(const std::string& filePath) + { + std::scoped_lock lock(Detail::getRegistryMutex()); + const auto& registry = Detail::getRegistry(); + + json_t functions = json_t::array(); + + for (size_t i = 0; i < registry.size(); ++i) + { + const auto* func = registry[i]; + + json_t parentIndices = json_t::array(); + for (const auto* parent : func->getParents()) + { + auto it = std::find(registry.begin(), registry.end(), parent); + if (it != registry.end()) + parentIndices.push_back(std::distance(registry.begin(), it)); + } + + json_t childIndices = json_t::array(); + for (const auto* child : func->getChildren()) + { + auto it = std::find(registry.begin(), registry.end(), child); + if (it != registry.end()) + childIndices.push_back(std::distance(registry.begin(), it)); + } + + functions.push_back( + { + { "name", func->getName() }, + { "callCount", func->getCallCount() }, + { "minTime", func->getMinTime() }, + { "maxTime", func->getMaxTime() }, + { "avgTime", func->getAverageTime() }, + { "totalTime", func->getTotalTime() }, + { "parents", parentIndices }, + { "children", childIndices }, + }); + } + + json_t root = { { "functions", functions } }; + + try + { + Json::WriteToFile(filePath, root); + return true; + } + catch (...) + { + return false; + } + } + + bool hasExtension(const std::string& path, const std::string& ext) + { + if (path.size() < ext.size()) + return false; + + // Case insensitive extension comparison + auto pathEnd = path.substr(path.size() - ext.size()); + std::transform(pathEnd.begin(), pathEnd.end(), pathEnd.begin(), ::tolower); + return pathEnd == ext; + } + } // namespace + + bool exportData(const std::string& filePath) + { + if (hasExtension(filePath, ".json")) + return writeJSON(filePath); + return writeCSV(filePath); } } // namespace OpenRCT2::Profiling diff --git a/src/openrct2/profiling/Profiling.h b/src/openrct2/profiling/Profiling.h index ddc3718c15..1fe17d86e5 100644 --- a/src/openrct2/profiling/Profiling.h +++ b/src/openrct2/profiling/Profiling.h @@ -15,134 +15,140 @@ #include #include #include -#include #include namespace OpenRCT2::Profiling { - void Enable(); - void Disable(); - bool IsEnabled(); + void enable(); + void disable(); + bool isEnabled(); struct Function { virtual ~Function() = default; - // This returns the full function prototype not just the name. - virtual const char* GetName() const noexcept = 0; - - // Total calls made to the function. - virtual uint64_t GetCallCount() const noexcept = 0; - - // Returns a small window of the most recent times. - virtual std::vector GetTimeSamples() const = 0; - - // Returns all time accumulated in microseconds. + virtual const char* getName() const noexcept = 0; + virtual uint64_t getCallCount() const noexcept = 0; + virtual std::vector getTimeSamples() const = 0; virtual double getTotalTime() const = 0; + virtual double getMinTime() const = 0; + virtual double getMaxTime() const = 0; - // Returns the min. time in microseconds. - virtual double GetMinTime() const = 0; + double getAverageTime() const + { + const auto count = getCallCount(); + return count > 0 ? getTotalTime() / static_cast(count) : 0.0; + } - // Returns the max. time in microseconds. - virtual double GetMaxTime() const = 0; - - // Returns a list of all functions that called this function. - virtual std::vector GetParents() const = 0; - - // Returns a list of function this function is calling. - virtual std::vector GetChildren() const = 0; + virtual std::vector getParents() const = 0; + virtual std::vector getChildren() const = 0; }; namespace Detail { - static constexpr auto MaxSamplesSize = 1024; - static constexpr auto MaxNameSize = 250; + static constexpr size_t MaxSamplesSize = 1024; - std::vector& GetRegistry(); + struct FunctionInternal; + + std::vector& getRegistry(); + std::mutex& getRegistryMutex(); + void registerFunction(FunctionInternal* func); struct FunctionInternal : Function { FunctionInternal() { - GetRegistry().push_back(this); + registerFunction(this); } virtual ~FunctionInternal() = default; - // Functions marked MT require locking, this is per function basis. + // Mutex only for call graph access, not the hot path. mutable std::mutex Mutex; - std::array Name{}; + // Atomic and lock free + std::atomic CallCount{ 0 }; + std::atomic TotalTimeNs{ 0 }; + std::atomic MinTimeNs{ 0 }; + std::atomic MaxTimeNs{ 0 }; - // Call count of function. - std::atomic CallCount{}; + // Circular buffer for recent samples in nanoseconds + std::array, MaxSamplesSize> Samples{}; + std::atomic SampleIndex{ 0 }; - // Function times in microseconds. - std::array Samples{}; + // Call graph, protected by Mutex, but only accessed on new relationships + std::vector Parents; + std::vector Children; - // Used internally to write into Samples without a lock. - std::atomic SampleIterator{}; + // Fast path cache, skip lock if we just linked this parent + std::atomic LastParent{ nullptr }; - double MinTimeUs{}; - - double MaxTimeUs{}; - - double TotalTimeUs{}; - - // Functions that called us. - std::unordered_set Parents; - - // Functions that this function called. - std::unordered_set Children; - - uint64_t GetCallCount() const noexcept override + // Lock free min update + void updateMin(uint64_t value) { - return CallCount.load(); + uint64_t current = MinTimeNs.load(std::memory_order_relaxed); + while (current == 0 || value < current) + { + if (MinTimeNs.compare_exchange_weak(current, value, std::memory_order_relaxed)) + break; + } } - std::vector GetTimeSamples() const override + // Lock free max update + void updateMax(uint64_t value) { - const auto numSamples = std::min(SampleIterator.load(), Samples.size()); - return { Samples.begin(), Samples.begin() + numSamples }; + uint64_t current = MaxTimeNs.load(std::memory_order_relaxed); + while (value > current) + { + if (MaxTimeNs.compare_exchange_weak(current, value, std::memory_order_relaxed)) + break; + } } - std::vector GetParents() const override + bool tryAddParent(FunctionInternal* parent); + bool tryAddChild(FunctionInternal* child); + + uint64_t getCallCount() const noexcept override + { + return CallCount.load(std::memory_order_relaxed); + } + + std::vector getTimeSamples() const override; + + double getTotalTime() const override + { + return static_cast(TotalTimeNs.load(std::memory_order_relaxed)) / 1000.0; + } + + double getMinTime() const override + { + return static_cast(MinTimeNs.load(std::memory_order_relaxed)) / 1000.0; + } + + double getMaxTime() const override + { + return static_cast(MaxTimeNs.load(std::memory_order_relaxed)) / 1000.0; + } + + std::vector getParents() const override { std::scoped_lock lock(Mutex); return { Parents.begin(), Parents.end() }; } - std::vector GetChildren() const override + std::vector getChildren() const override { std::scoped_lock lock(Mutex); return { Children.begin(), Children.end() }; } - - double getTotalTime() const override - { - std::scoped_lock lock(Mutex); - return TotalTimeUs; - } - - double GetMinTime() const override - { - std::scoped_lock lock(Mutex); - return MinTimeUs; - } - - double GetMaxTime() const override - { - std::scoped_lock lock(Mutex); - return MaxTimeUs; - } }; template - struct FunctionWrapper : FunctionInternal + struct FunctionWrapper final : FunctionInternal { - const char* GetName() const noexcept override + const char* getName() const noexcept override { - return TName::Str(); + return TName::str(); } }; @@ -156,11 +162,12 @@ namespace OpenRCT2::Profiling static inline FunctionWrapper Data; }; - void FunctionEnter(Function& func); - void FunctionExit(Function& func); + void functionEnter(FunctionInternal& func); + void functionExit(FunctionInternal& func); } // namespace Detail + // RAII wrapper for automatic function timing template class ScopedProfiling { @@ -168,29 +175,33 @@ namespace OpenRCT2::Profiling T& _func; public: - ScopedProfiling(T& func) - : _enabled{ IsEnabled() } + explicit ScopedProfiling(T& func) + : _enabled(isEnabled()) , _func(func) { if (_enabled) { - Detail::FunctionEnter(_func); + Detail::functionEnter(_func); } } + ~ScopedProfiling() { - if (!_enabled) - return; - Detail::FunctionExit(_func); + if (_enabled) + { + Detail::functionExit(_func); + } } + + // Not copyable and not movable + ScopedProfiling(const ScopedProfiling&) = delete; + ScopedProfiling& operator=(const ScopedProfiling&) = delete; + ScopedProfiling(ScopedProfiling&&) = delete; + ScopedProfiling& operator=(ScopedProfiling&&) = delete; }; - // Clears all the current data of each function. - void ResetData(); - - // Returns all functions. - const std::vector& GetData(); - - bool ExportCSV(const std::string& filePath); + void resetData(); + const std::vector& getData(); + [[nodiscard]] bool exportData(const std::string& filePath); } // namespace OpenRCT2::Profiling diff --git a/src/openrct2/profiling/ProfilingMacros.hpp b/src/openrct2/profiling/ProfilingMacros.hpp index 3474bb00e6..c7f1f5695e 100644 --- a/src/openrct2/profiling/ProfilingMacros.hpp +++ b/src/openrct2/profiling/ProfilingMacros.hpp @@ -22,7 +22,7 @@ namespace OpenRCT2::Profiling static constexpr auto _profiling_func_name = func; \ struct Profiler_FunctionLiteral \ { \ - static constexpr const char* Str() \ + static constexpr const char* str() \ { \ return _profiling_func_name; \ } \ diff --git a/src/openrct2/scripting/bindings/game/ScProfiler.hpp b/src/openrct2/scripting/bindings/game/ScProfiler.hpp index 932eee34fb..a2833ff68d 100644 --- a/src/openrct2/scripting/bindings/game/ScProfiler.hpp +++ b/src/openrct2/scripting/bindings/game/ScProfiler.hpp @@ -30,19 +30,20 @@ namespace OpenRCT2::Scripting private: DukValue getData() { - const auto& data = Profiling::GetData(); + const auto& data = Profiling::getData(); duk_push_array(_ctx); duk_uarridx_t index = 0; for (const auto& f : data) { DukObject obj(_ctx); - obj.Set("name", f->GetName()); - obj.Set("callCount", f->GetCallCount()); - obj.Set("minTime", f->GetMinTime()); - obj.Set("maxTime", f->GetMaxTime()); + obj.Set("name", f->getName()); + obj.Set("callCount", f->getCallCount()); + obj.Set("minTime", f->getMinTime()); + obj.Set("maxTime", f->getMaxTime()); obj.Set("totalTime", f->getTotalTime()); - obj.Set("parents", GetFunctionIndexArray(data, f->GetParents())); - obj.Set("children", GetFunctionIndexArray(data, f->GetChildren())); + obj.Set("averageTime", f->getAverageTime()); + obj.Set("parents", GetFunctionIndexArray(data, f->getParents())); + obj.Set("children", GetFunctionIndexArray(data, f->getChildren())); obj.Take().push(); duk_put_prop_index(_ctx, /* duk stack index */ -2, index); index++; @@ -71,22 +72,22 @@ namespace OpenRCT2::Scripting void start() { - Profiling::Enable(); + Profiling::enable(); } void stop() { - Profiling::Disable(); + Profiling::disable(); } void reset() { - Profiling::ResetData(); + Profiling::resetData(); } bool enabled_get() const { - return Profiling::IsEnabled(); + return Profiling::isEnabled(); } public: