4#include "Stroika/Frameworks/StroikaPreComp.h"
7#include "Stroika/Foundation/Common/GUID.h"
8#include "Stroika/Foundation/Common/Property.h"
13#include "OperationalStatistics.h"
21using namespace Stroika::Foundation::Time;
26using namespace Stroika::Samples::HTMLUI;
38OperationalStatisticsMgr::ProcessAPICmd::~ProcessAPICmd ()
41 sThe.Add_ (Rec_{Rec_::Kind::eAPI, now, now - fStart_});
44void OperationalStatisticsMgr::ProcessAPICmd::NoteError ()
47 sThe.Add_ (Rec_{.fKind = Rec_::Kind::eAPIError, .fAt = now, .fDuration = 0s});
55void OperationalStatisticsMgr::RecordActiveRunningTasksCount (
size_t length)
58 sThe.Add_ (Rec_{.fKind = Rec_::Kind::eAPIActiveRunningTasks, .fAt = now, .fDuration = 0s, .fLength = length});
61void OperationalStatisticsMgr::RecordOpenConnectionCount (
size_t length)
64 sThe.Add_ (Rec_{.fKind = Rec_::Kind::eAPIOpenConnectionCount, .fAt = now, .fDuration = 0s, .fLength = length});
67void OperationalStatisticsMgr::RecordProcessingConnectionCount (
size_t length)
70 sThe.Add_ (Rec_{.fKind = Rec_::Kind::eAPIProcessingConnectionCount, .fAt = now, .fDuration = 0s, .fLength = length});
73auto OperationalStatisticsMgr::GetStatistics () const -> Statistics
82 lock_guard lk{fMutex_};
84 [&] (
const Rec_& r) {
return r.fAt >= skipBefore and r.fKind != Rec_::Kind::eNull; });
89 if (r.fKind == Rec_::Kind::eAPI)
93 if (not apiTimes.
empty ()) {
94 result.fRecentAPI.fMeanDuration =
Duration{Math::Mean (apiTimes)};
95 result.fRecentAPI.fMedianDuration =
Duration{Math::Median (apiTimes)};
96 result.fRecentAPI.fMaxDuration =
Duration{*apiTimes.
Max ()};
98 result.fRecentAPI.fCallsCompleted =
static_cast<unsigned int> (apiTimes.
length ());
99 result.fRecentAPI.fErrors =
100 static_cast<unsigned int> (allApplicable.
Count ([] (
const Rec_& r) {
return r.fKind == Rec_::Kind::eAPIError; }));
104 if (r.fKind == Rec_::Kind::eAPIActiveRunningTasks)
105 return static_cast<float> (r.fLength);
108 if (not activeRunningWSAPITasks.
empty ()) {
109 result.fRecentAPI.fMedianRunningAPITasks = Math::Median (activeRunningWSAPITasks);
time_point< RealtimeClock, DurationSeconds > TimePointSeconds
TimePointSeconds is a simpler approach to chrono::time_point, which doesn't require using templates e...
A generalization of a vector: a container whose elements are keyed by the natural numbers.
nonvirtual RESULT_CONTAINER Where(INCLUDE_PREDICATE &&includeIfTrue) const
Duration is a chrono::duration<double> (=.
Iterable<T> is a base class for containers which easily produce an Iterator<T> to traverse them.
nonvirtual optional< T > Max() const
nonvirtual size_t length() const
STL-ish alias for size() - really in STL only used in string, I think, but still makes sense as an al...
nonvirtual RESULT_CONTAINER Map(ELEMENT_MAPPER &&elementMapper) const
functional API which iterates over all members of an Iterable, applies a map function to each element...
nonvirtual size_t Count() const
with no args, same as size, with function filter arg, returns number of items that pass.
nonvirtual bool empty() const
Returns true iff size() == 0.