重新设置代码格式
This commit is contained in:
@@ -9,14 +9,13 @@ protected:
|
||||
|
||||
[[nodiscard]] static uint64_t get_current_ms() {
|
||||
using namespace std::chrono;
|
||||
return duration_cast<milliseconds>(
|
||||
steady_clock::now().time_since_epoch()
|
||||
).count();
|
||||
return duration_cast<milliseconds>(steady_clock::now().time_since_epoch())
|
||||
.count();
|
||||
}
|
||||
|
||||
public:
|
||||
Base_Statistics() : start_time(get_current_ms()) {}
|
||||
virtual JSON to_json() const = 0;
|
||||
virtual JSON to_json() const = 0;
|
||||
virtual ~Base_Statistics() = default;
|
||||
|
||||
unsigned int get_start_time() const { return start_time; }
|
||||
@@ -25,7 +24,6 @@ public:
|
||||
// Speed Statistics 类,继承自 Base_Statistics\
|
||||
// 单位B/s
|
||||
|
||||
|
||||
class Speed_Statistics : public Base_Statistics {
|
||||
public:
|
||||
double cur_total{};
|
||||
@@ -33,8 +31,7 @@ public:
|
||||
double average_speed{};
|
||||
size_t times{};
|
||||
|
||||
Speed_Statistics& operator+=(const Speed_Statistics& rhs)
|
||||
{
|
||||
Speed_Statistics &operator+=(const Speed_Statistics &rhs) {
|
||||
this->cur_total += rhs.cur_total;
|
||||
this->instant_speed += rhs.instant_speed;
|
||||
this->average_speed += rhs.average_speed;
|
||||
@@ -42,9 +39,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
Speed_Statistics() {
|
||||
clear();
|
||||
}
|
||||
Speed_Statistics() { clear(); }
|
||||
|
||||
void clear() {
|
||||
cur_total = 0;
|
||||
@@ -55,11 +50,8 @@ public:
|
||||
|
||||
[[nodiscard]] JSON to_json() const override {
|
||||
JSON ret = JSON::object();
|
||||
// Ret_J(cur_total)
|
||||
Ret_J(instant_speed)
|
||||
Ret_J(average_speed)
|
||||
Ret_J(times)
|
||||
return ret;
|
||||
// Ret_J(cur_total)
|
||||
Ret_J(instant_speed) Ret_J(average_speed) Ret_J(times) return ret;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string to_string() const {
|
||||
@@ -82,7 +74,7 @@ public:
|
||||
instant_speed = cur_total / true_period_ms * 1000;
|
||||
|
||||
// 转换成 KB/s
|
||||
//instant_speed /= 1024.0f;
|
||||
// instant_speed /= 1024.0f;
|
||||
|
||||
// 平均速度
|
||||
double average_times = 10.0f;
|
||||
@@ -109,20 +101,14 @@ public:
|
||||
size_t times = 0;
|
||||
[[nodiscard]] JSON to_json() const override {
|
||||
JSON ret = JSON::object();
|
||||
Ret_J(max)
|
||||
Ret_J(min)
|
||||
Ret_J(average)
|
||||
Ret_J(instant)
|
||||
return ret;
|
||||
Ret_J(max) Ret_J(min) Ret_J(average) Ret_J(instant) return ret;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string to_string() const {
|
||||
return VAR_STR_5(min, max, average, instant, times);
|
||||
}
|
||||
|
||||
Value_Statistics() {
|
||||
clear();
|
||||
}
|
||||
Value_Statistics() { clear(); }
|
||||
|
||||
void clear() {
|
||||
max = std::numeric_limits<double>::min();
|
||||
@@ -157,16 +143,10 @@ public:
|
||||
unsigned int total_max{}; // 总次数
|
||||
[[nodiscard]] JSON to_json() const override {
|
||||
JSON ret = JSON::object();
|
||||
Ret_J(instant)
|
||||
Ret_J(average)
|
||||
Ret_J(count)
|
||||
Ret_J(total)
|
||||
Ret_J(total_max)
|
||||
return ret;
|
||||
}
|
||||
Probability_Statistics() {
|
||||
clear();
|
||||
Ret_J(instant) Ret_J(average) Ret_J(count) Ret_J(total)
|
||||
Ret_J(total_max) return ret;
|
||||
}
|
||||
Probability_Statistics() { clear(); }
|
||||
|
||||
void clear() {
|
||||
instant = 0;
|
||||
|
||||
Reference in New Issue
Block a user