mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-12 07:43:43 +00:00
feat(servers): time the main loops' phases and the known heavy spots
Frames and phase scopes in the world, auth, chat and UGC loops (packets per type, entities, physics, ghosting, replica, spawners, log flush, saves, web requests by route). Scopes at LoadPlayer, CreateEntity, each component's construction, InventoryComponent::LoadXml, script timers and a world's zone load; game database queries in the query helpers; CDClient statements timed through sqlite3_trace_v2 as CDClient <table> (CppSQLite3DB gets a handle accessor). Task 96. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef __MYSQLDATABASE__H__
|
||||
#define __MYSQLDATABASE__H__
|
||||
|
||||
#include "Profiler.h"
|
||||
#include <conncpp.hpp>
|
||||
#include <memory>
|
||||
|
||||
@@ -518,6 +519,7 @@ private:
|
||||
// The return type is a PreparedStmtResultSet which keeps the PreparedStatement alive alongside the ResultSet.
|
||||
template<typename... Args>
|
||||
inline PreparedStmtResultSet ExecuteSelect(const std::string& query, Args&&... args) {
|
||||
Profiler::Scope profile("Database query", Profiler::Phase::DATABASE);
|
||||
PreparedStmtResultSet toReturn;
|
||||
toReturn.m_stmt.reset(CreatePreppedStmt(query));
|
||||
SetParams(toReturn.m_stmt, std::forward<Args>(args)...);
|
||||
@@ -528,6 +530,7 @@ private:
|
||||
|
||||
template<typename... Args>
|
||||
inline void ExecuteDelete(const std::string& query, Args&&... args) {
|
||||
Profiler::Scope profile("Database query", Profiler::Phase::DATABASE);
|
||||
std::unique_ptr<sql::PreparedStatement> preppedStmt(CreatePreppedStmt(query));
|
||||
SetParams(preppedStmt, std::forward<Args>(args)...);
|
||||
DLU_SQL_TRY_CATCH_RETHROW(preppedStmt->execute());
|
||||
@@ -535,6 +538,7 @@ private:
|
||||
|
||||
template<typename... Args>
|
||||
inline int32_t ExecuteUpdate(const std::string& query, Args&&... args) {
|
||||
Profiler::Scope profile("Database query", Profiler::Phase::DATABASE);
|
||||
std::unique_ptr<sql::PreparedStatement> preppedStmt(CreatePreppedStmt(query));
|
||||
SetParams(preppedStmt, std::forward<Args>(args)...);
|
||||
DLU_SQL_TRY_CATCH_RETHROW(return preppedStmt->executeUpdate());
|
||||
@@ -542,6 +546,7 @@ private:
|
||||
|
||||
template<typename... Args>
|
||||
inline bool ExecuteInsert(const std::string& query, Args&&... args) {
|
||||
Profiler::Scope profile("Database query", Profiler::Phase::DATABASE);
|
||||
std::unique_ptr<sql::PreparedStatement> preppedStmt(CreatePreppedStmt(query));
|
||||
SetParams(preppedStmt, std::forward<Args>(args)...);
|
||||
DLU_SQL_TRY_CATCH_RETHROW(return preppedStmt->execute());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef SQLITEDATABASE_H
|
||||
#define SQLITEDATABASE_H
|
||||
|
||||
#include "Profiler.h"
|
||||
#include "CppSQLite3.h"
|
||||
|
||||
#include "GameDatabase.h"
|
||||
@@ -502,6 +503,7 @@ private:
|
||||
// The return type is a unique_ptr to the result set, which is deleted automatically when it goes out of scope
|
||||
template<typename... Args>
|
||||
inline std::pair<CppSQLite3Statement, CppSQLite3Query> ExecuteSelect(const std::string& query, Args&&... args) {
|
||||
Profiler::Scope profile("Database query", Profiler::Phase::DATABASE);
|
||||
std::pair<CppSQLite3Statement, CppSQLite3Query> toReturn;
|
||||
toReturn.first = CreatePreppedStmt(query);
|
||||
SetParams(toReturn.first, std::forward<Args>(args)...);
|
||||
@@ -511,6 +513,7 @@ private:
|
||||
|
||||
template<typename... Args>
|
||||
inline void ExecuteDelete(const std::string& query, Args&&... args) {
|
||||
Profiler::Scope profile("Database query", Profiler::Phase::DATABASE);
|
||||
auto preppedStmt = CreatePreppedStmt(query);
|
||||
SetParams(preppedStmt, std::forward<Args>(args)...);
|
||||
DLU_SQL_TRY_CATCH_RETHROW(preppedStmt.execDML());
|
||||
@@ -518,6 +521,7 @@ private:
|
||||
|
||||
template<typename... Args>
|
||||
inline int32_t ExecuteUpdate(const std::string& query, Args&&... args) {
|
||||
Profiler::Scope profile("Database query", Profiler::Phase::DATABASE);
|
||||
auto preppedStmt = CreatePreppedStmt(query);
|
||||
SetParams(preppedStmt, std::forward<Args>(args)...);
|
||||
DLU_SQL_TRY_CATCH_RETHROW(return preppedStmt.execDML());
|
||||
@@ -525,6 +529,7 @@ private:
|
||||
|
||||
template<typename... Args>
|
||||
inline int ExecuteInsert(const std::string& query, Args&&... args) {
|
||||
Profiler::Scope profile("Database query", Profiler::Phase::DATABASE);
|
||||
auto preppedStmt = CreatePreppedStmt(query);
|
||||
SetParams(preppedStmt, std::forward<Args>(args)...);
|
||||
DLU_SQL_TRY_CATCH_RETHROW(return preppedStmt.execDML());
|
||||
|
||||
Reference in New Issue
Block a user