dos/my_fin.cpp

34 lines
1.6 KiB
C++

#include "my_start.hpp"
#include <cstdlib>
void my_fin() {
auto end_timestamp = std::chrono::system_clock::now();
auto end_time_t = std::chrono::system_clock::to_time_t(end_timestamp);
auto end_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end_timestamp.time_since_epoch()) % 1000;
auto duration = end_timestamp - start_timestamp;
auto hours = std::chrono::duration_cast<std::chrono::hours>(duration);
auto minutes = std::chrono::duration_cast<std::chrono::minutes>(duration % std::chrono::hours(1));
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(duration % std::chrono::minutes(1));
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(duration % std::chrono::seconds(1));
std::cout << "Worked for ";
if (duration < std::chrono::minutes(2)) {
double total_seconds = std::chrono::duration<double>(duration).count();
std::cout << std::fixed << std::setprecision(3) << total_seconds << " seconds";
} else {
if (hours.count() > 0) std::cout << hours.count() << "h ";
if (minutes.count() > 0) std::cout << minutes.count() << "m ";
std::cout << seconds.count() << "s " << milliseconds.count() << "ms";
}
std::cout << std::endl;
std::cout << "Sent " << (n_ok_requests + n_fail_requests) << " requests ("
<< n_ok_requests << " ok, " << n_fail_requests << " failed)" << std::endl;
std::cout << "DosAtk stopped at " << std::put_time(std::localtime(&end_time_t), "%Y-%m-%d %H:%M:%S")
<< "." << std::setfill('0') << std::setw(3) << end_ms.count() << std::endl;
std::exit(0);
}