fix project 2 bugz

master
Riley S 1 year ago
parent 1570e9f069
commit 1a4a72ecdd
  1. 5
      main.cpp
  2. 14
      project/metrics.h

@ -16,6 +16,8 @@
using json = nlohmann::json;
std::mutex metrics_mutex {};
auto onClientConnected(networked& client)
{
sscout << "Accepted Client on Server.\n";
@ -77,6 +79,7 @@ auto execute_as_client(std::string ipaddress, std::uint16_t port)
net_client.message_received += [&](std::string& message)
{
auto elapsed = clock.elapsed<double, std::milli>();
const std::lock_guard<std::mutex> lock(metrics_mutex);
auto client_num = this_job.client_metrics.size()+1;
//UX
sscout << client_num << math::numerical_suffix(client_num) << " client response\n"
@ -151,4 +154,4 @@ int main() {
<< "╘════════════════════╝\n";
return 0;
}
}

@ -37,15 +37,23 @@ namespace metrics
inline void to_json(json& j, const job& p)
{
auto total_trip_time = 0.;
auto summation_time = 0.f;
for(auto&& client : p.client_metrics)
{
summation_time += client.trip_time;
#ifdef THREADED
total_trip_time = client.trip_time > total_trip_time ? client.trip_time : total_trip_time;
#else
total_trip_time += client.trip_time;
j = json{
#endif
}
j = json{
{ "operation", p.operation },
{ "total_trip_time", total_trip_time },
{ "average_trip_time",total_trip_time / p.client_metrics.size() },
{ "average_trip_time",summation_time / p.client_metrics.size() },
{ "client_metrics", p.client_metrics}
};
}
inline std::vector<job> job_metrics{};
}
}

Loading…
Cancel
Save