|
@ -65,3 +65,77 @@ double Benchmark::common_code_from_string(TIME format) noexcept { |
|
|
} |
|
|
} |
|
|
return time_format(start, format) / (double)all_common_codes_str.size(); |
|
|
return time_format(start, format) / (double)all_common_codes_str.size(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double Benchmark::common_code_to_raw_code(TIME format) noexcept { |
|
|
|
|
|
if (!data_ready) { |
|
|
|
|
|
return -1; // data no ready -> skip
|
|
|
|
|
|
} |
|
|
|
|
|
auto start = clock(); |
|
|
|
|
|
for (auto &&common_code : all_common_codes) { |
|
|
|
|
|
RawCode{std::forward<CommonCode>(common_code)}; |
|
|
|
|
|
} |
|
|
|
|
|
return time_format(start, format) / (double)all_common_codes.size(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double Benchmark::raw_code_to_common_code(TIME format) noexcept { |
|
|
|
|
|
if (!data_ready) { |
|
|
|
|
|
return -1; // data no ready -> skip
|
|
|
|
|
|
} |
|
|
|
|
|
auto start = clock(); |
|
|
|
|
|
for (auto &&raw_code : all_raw_codes) { |
|
|
|
|
|
raw_code.to_common_code(); |
|
|
|
|
|
} |
|
|
|
|
|
return time_format(start, format) / (double)all_raw_codes.size(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double Benchmark::common_code_to_short_code(TIME format) noexcept { |
|
|
|
|
|
if (!data_ready) { |
|
|
|
|
|
return -1; // data no ready -> skip
|
|
|
|
|
|
} |
|
|
|
|
|
uint32_t num = 0; |
|
|
|
|
|
ShortCode::speed_up(ShortCode::NORMAL); |
|
|
|
|
|
auto start = clock(); |
|
|
|
|
|
for (uint64_t i = 0; i < all_common_codes.size(); i += 1000) { |
|
|
|
|
|
ShortCode{all_common_codes[i]}; |
|
|
|
|
|
++num; |
|
|
|
|
|
} |
|
|
|
|
|
return time_format(start, format) / (double)num; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double Benchmark::short_code_to_common_code(TIME format) noexcept { |
|
|
|
|
|
if (!data_ready) { |
|
|
|
|
|
return -1; // data no ready -> skip
|
|
|
|
|
|
} |
|
|
|
|
|
uint32_t num = 0; |
|
|
|
|
|
ShortCode::speed_up(ShortCode::NORMAL); |
|
|
|
|
|
auto start = clock(); |
|
|
|
|
|
for (uint64_t i = 0; i < all_short_codes.size(); i += 1000) { |
|
|
|
|
|
all_short_codes[i].to_common_code(); |
|
|
|
|
|
++num; |
|
|
|
|
|
} |
|
|
|
|
|
return time_format(start, format) / (double)num; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double Benchmark::common_code_to_short_code_fast(TIME format) noexcept { |
|
|
|
|
|
if (!data_ready) { |
|
|
|
|
|
return -1; // data no ready -> skip
|
|
|
|
|
|
} |
|
|
|
|
|
ShortCode::speed_up(ShortCode::FAST); |
|
|
|
|
|
auto start = clock(); |
|
|
|
|
|
for (auto &&common_code : all_common_codes) { |
|
|
|
|
|
ShortCode{std::forward<CommonCode>(common_code)}; |
|
|
|
|
|
} |
|
|
|
|
|
return time_format(start, format) / (double)all_common_codes.size(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double Benchmark::short_code_to_common_code_fast(TIME format) noexcept { |
|
|
|
|
|
if (!data_ready) { |
|
|
|
|
|
return -1; // data no ready -> skip
|
|
|
|
|
|
} |
|
|
|
|
|
ShortCode::speed_up(ShortCode::FAST); |
|
|
|
|
|
auto start = clock(); |
|
|
|
|
|
for (auto &&short_code : all_short_codes) { |
|
|
|
|
|
short_code.to_common_code(); |
|
|
|
|
|
} |
|
|
|
|
|
return time_format(start, format) / (double)all_short_codes.size(); |
|
|
|
|
|
} |
|
|