fix project 2 bugz
This commit is contained in:
parent
1570e9f069
commit
1a4a72ecdd
3
main.cpp
3
main.cpp
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
std::mutex metrics_mutex {};
|
||||||
|
|
||||||
auto onClientConnected(networked& client)
|
auto onClientConnected(networked& client)
|
||||||
{
|
{
|
||||||
sscout << "Accepted Client on Server.\n";
|
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)
|
net_client.message_received += [&](std::string& message)
|
||||||
{
|
{
|
||||||
auto elapsed = clock.elapsed<double, std::milli>();
|
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;
|
auto client_num = this_job.client_metrics.size()+1;
|
||||||
//UX
|
//UX
|
||||||
sscout << client_num << math::numerical_suffix(client_num) << " client response\n"
|
sscout << client_num << math::numerical_suffix(client_num) << " client response\n"
|
||||||
|
@ -37,12 +37,20 @@ namespace metrics
|
|||||||
inline void to_json(json& j, const job& p)
|
inline void to_json(json& j, const job& p)
|
||||||
{
|
{
|
||||||
auto total_trip_time = 0.;
|
auto total_trip_time = 0.;
|
||||||
|
auto summation_time = 0.f;
|
||||||
for(auto&& client : p.client_metrics)
|
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;
|
total_trip_time += client.trip_time;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
j = json{
|
j = json{
|
||||||
{ "operation", p.operation },
|
{ "operation", p.operation },
|
||||||
{ "total_trip_time", total_trip_time },
|
{ "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}
|
{ "client_metrics", p.client_metrics}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user