Skip to content

Commit a25dad0

Browse files
committed
fixup! SILKit-1607: Fix performance
1 parent a38a80a commit a25dad0

File tree

4 files changed

+15
-30
lines changed

4 files changed

+15
-30
lines changed

SilKit/source/services/logging/ILoggerInternal.hpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ class LoggerMessage
7373
{
7474
}
7575

76-
template <typename... Args>
77-
void SetMessage(fmt::format_string<Args...> fmt, Args&&... args)
78-
{
79-
_msg = fmt::format(fmt, std::forward<Args>(args)...);
80-
}
8176

8277
template <typename... Args>
8378
void FormatMessage(fmt::format_string<Args...> fmt, Args&&... args)
@@ -126,21 +121,11 @@ class LoggerMessage
126121
return _keyValues;
127122
}
128123

129-
bool HasKeyValues() const
130-
{
131-
return !_keyValues.empty();
132-
}
133-
134124
auto GetMsgString() const -> const std::string&
135125
{
136126
return _msg;
137127
}
138128

139-
auto GetLogger() const -> ILoggerInternal*
140-
{
141-
return _logger;
142-
}
143-
144129
void Dispatch()
145130
{
146131
if (_logger->GetLogLevel() <= _level)

SilKit/source/services/logging/MessageTracing.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ void TraceRx(Logging::ILoggerInternal* logger, const Core::IServiceEndpoint* add
5858

5959
for (const auto& pair : addr->GetServiceDescriptor().to_keyValues())
6060
{
61-
lm.FormatKeyValue(pair.first, pair.second);
61+
lm.SetKeyValue(pair.first, pair.second);
6262
}
63-
lm.FormatKeyValue(Logging::Keys::from, from.GetParticipantName());
63+
lm.SetKeyValue(Logging::Keys::from, from.GetParticipantName());
6464
lm.FormatKeyValue(Logging::Keys::msg, "{}", msg);
6565

6666
auto virtualTimeStamp = GetTimestamp(msg);
@@ -80,7 +80,7 @@ void TraceTx(Logging::ILoggerInternal* logger, const Core::IServiceEndpoint* add
8080

8181
for (const auto& pair : addr->GetServiceDescriptor().to_keyValues())
8282
{
83-
lm.FormatKeyValue(pair.first, pair.second);
83+
lm.SetKeyValue(pair.first, pair.second);
8484
}
8585

8686
lm.FormatKeyValue(Logging::Keys::msg, "{}", msg);

SilKit/source/services/orchestration/SystemStateTracker.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ auto SystemStateTracker::UpdateParticipantStatus(const ParticipantStatus& newPar
143143
Log::LoggerMessage lm{_logger, Log::Level::Debug};
144144
lm.SetMessage("Updating participant status");
145145
lm.SetKeyValue(Log::Keys::participantName, participantName);
146-
lm.SetKeyValue(Log::Keys::oldParticipantState, fmt::format("{}", oldParticipantState));
147-
lm.SetKeyValue(Log::Keys::newParticipantState, fmt::format("{}", newParticipantState));
146+
lm.FormatKeyValue(Log::Keys::oldParticipantState, "{}", oldParticipantState);
147+
lm.FormatKeyValue(Log::Keys::newParticipantState, "{}", newParticipantState);
148148
lm.Dispatch();
149149
}
150150
// Check if transition from the old to the new participant state is valid
@@ -155,8 +155,8 @@ auto SystemStateTracker::UpdateParticipantStatus(const ParticipantStatus& newPar
155155
Log::LoggerMessage lm{_logger, logLevel};
156156
lm.SetMessage("SystemMonitor detected invalid ParticipantState transition!");
157157
lm.SetKeyValue(Log::Keys::participantName, participantName);
158-
lm.SetKeyValue(Log::Keys::oldParticipantState, fmt::format("{}", oldParticipantState));
159-
lm.SetKeyValue(Log::Keys::newParticipantState, fmt::format("{}", newParticipantState));
158+
lm.FormatKeyValue(Log::Keys::oldParticipantState, "{}", oldParticipantState);
159+
lm.FormatKeyValue(Log::Keys::newParticipantState, "{}", newParticipantState);
160160
lm.SetKeyValue(Log::Keys::enterTime, FormatTimePoint(newParticipantStatus.enterTime));
161161
lm.SetKeyValue(Log::Keys::enterReason, newParticipantStatus.enterReason);
162162
lm.Dispatch();
@@ -195,8 +195,8 @@ auto SystemStateTracker::UpdateParticipantStatus(const ParticipantStatus& newPar
195195
Log::LoggerMessage lm{_logger, Log::Level::Debug};
196196
lm.SetMessage("Computed new system state update!");
197197
lm.SetKeyValue(Log::Keys::participantName, participantName);
198-
lm.SetKeyValue(Log::Keys::oldParticipantState, fmt::format("{}", oldSystemState));
199-
lm.SetKeyValue(Log::Keys::newParticipantState, fmt::format("{}", newSystemState));
198+
lm.FormatKeyValue(Log::Keys::oldParticipantState, "{}", oldSystemState);
199+
lm.FormatKeyValue(Log::Keys::newParticipantState, "{}", newSystemState);
200200
lm.Dispatch();
201201
}
202202

@@ -205,8 +205,8 @@ auto SystemStateTracker::UpdateParticipantStatus(const ParticipantStatus& newPar
205205
Log::LoggerMessage lm{_logger, Log::Level::Debug};
206206
lm.SetMessage("The system state has changed!");
207207
lm.SetKeyValue(Log::Keys::participantName, participantName);
208-
lm.SetKeyValue(Log::Keys::oldParticipantState, fmt::format("{}", oldSystemState));
209-
lm.SetKeyValue(Log::Keys::newParticipantState, fmt::format("{}", newSystemState));
208+
lm.FormatKeyValue(Log::Keys::oldParticipantState, "{}", oldSystemState);
209+
lm.FormatKeyValue(Log::Keys::newParticipantState, "{}", newSystemState);
210210
lm.Dispatch();
211211

212212
_systemState = newSystemState;

SilKit/source/services/orchestration/TimeSyncService.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,8 @@ void TimeSyncService::ExecuteSimStep(std::chrono::nanoseconds timePoint, std::ch
492492
{
493493
Logging::LoggerMessage lm{_logger, Logging::Level::Trace};
494494
lm.SetMessage("Starting next Simulation Step.");
495-
lm.SetKeyValue(Logging::Keys::waitingTime, fmt::format("{}", std::chrono::duration_cast<DoubleMSecs>(_waitTimeMonitor.CurrentDuration()).count()));
496-
lm.SetKeyValue(Logging::Keys::virtualTimeNS, fmt::format("{}", timePoint.count()));
495+
lm.FormatKeyValue(Logging::Keys::waitingTime, "{}", std::chrono::duration_cast<DoubleMSecs>(_waitTimeMonitor.CurrentDuration()).count());
496+
lm.FormatKeyValue(Logging::Keys::virtualTimeNS, "{}", timePoint.count());
497497
lm.Dispatch();
498498
}
499499

@@ -536,8 +536,8 @@ void TimeSyncService::LogicalSimStepCompleted(std::chrono::duration<double, std:
536536
_simStepCounterMetric->Add(1);
537537
Logging::LoggerMessage lm{_logger, Logging::Level::Trace};
538538
lm.SetMessage("Finished Simulation Step.");
539-
lm.SetKeyValue(Logging::Keys::executionTime, fmt::format("{}", logicalSimStepTimeMs.count()));
540-
lm.SetKeyValue(Logging::Keys::virtualTimeNS, fmt::format("{}", Now().count()));
539+
lm.FormatKeyValue(Logging::Keys::executionTime, "{}", logicalSimStepTimeMs.count());
540+
lm.FormatKeyValue(Logging::Keys::virtualTimeNS, "{}", Now().count());
541541
lm.Dispatch();
542542
_waitTimeMonitor.StartMeasurement();
543543
}

0 commit comments

Comments
 (0)