|  | @ -1,11 +1,5 @@ | 
			
		
	
		
		
			
				
					|  |  | #include <string> |  |  |  | 
			
		
	
		
		
			
				
					|  |  | #include <vector> |  |  |  | 
			
		
	
		
		
			
				
					|  |  | #include "benchmark.h" |  |  | #include "benchmark.h" | 
			
		
	
		
		
			
				
					|  |  | #include "all_cases.h" |  |  | #include "all_cases.h" | 
			
		
	
		
		
			
				
					|  |  | #include "short_code.h" |  |  |  | 
			
		
	
		
		
			
				
					|  |  | #include "common_code.h" |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  | #include <iostream> |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | using klotski::Benchmark; |  |  | using klotski::Benchmark; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -29,109 +23,45 @@ double Benchmark::all_cases(TIME format) noexcept { | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | double Benchmark::short_code_to_string(TIME format) noexcept { |  |  | double Benchmark::short_code_to_string(TIME format) noexcept { | 
			
		
	
		
		
			
				
					
					|  |  |     /// data preparation
 |  |  |     if (!data_ready) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |     std::vector<ShortCode> data; |  |  |         return -1; // data no ready -> skip
 | 
			
				
				
			
		
	
		
		
			
				
					|  |  |     data.reserve(klotski::SHORT_CODE_LIMIT); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     for (uint32_t short_code = 0; short_code < klotski::SHORT_CODE_LIMIT; ++short_code) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         data.emplace_back(ShortCode::unsafe_create(short_code)); |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     /// start benchmark
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     auto start = clock(); |  |  |     auto start = clock(); | 
			
		
	
		
		
			
				
					
					|  |  |     for (const auto &short_code : data) { |  |  |     for (const auto &short_code : all_short_codes) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         short_code.to_string(); |  |  |         short_code.to_string(); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |     return time_format(start, format) / (double)data.size(); |  |  |     return time_format(start, format) / (double)all_short_codes.size(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | double Benchmark::short_code_from_string(TIME format) noexcept { |  |  | double Benchmark::short_code_from_string(TIME format) noexcept { | 
			
		
	
		
		
			
				
					
					|  |  |     /// data preparation
 |  |  |     if (!data_ready) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |     std::vector<std::string> data; |  |  |         return -1; // data no ready -> skip
 | 
			
				
				
			
		
	
		
		
			
				
					|  |  |     data.reserve(klotski::SHORT_CODE_LIMIT); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     for (uint32_t short_code = 0; short_code < klotski::SHORT_CODE_LIMIT; ++short_code) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         data.emplace_back(ShortCode::unsafe_create(short_code).to_string()); |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     /// start benchmark
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     auto start = clock(); |  |  |     auto start = clock(); | 
			
		
	
		
		
			
				
					
					|  |  |     for (auto &&short_code : data) { |  |  |     for (auto &&short_code : all_short_codes_str) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         ShortCode{std::forward<std::string>(short_code)}; |  |  |         ShortCode{std::forward<std::string>(short_code)}; | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |     return time_format(start, format) / (double)data.size(); |  |  |     return time_format(start, format) / (double)all_short_codes_str.size(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | double Benchmark::common_code_to_string(TIME format) noexcept { |  |  | double Benchmark::common_code_to_string(TIME format) noexcept { | 
			
		
	
		
		
			
				
					
					|  |  |     /// data preparation
 |  |  |     if (!data_ready) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |     std::vector<CommonCode> data; |  |  |         return -1; // data no ready -> skip
 | 
			
				
				
			
		
	
		
		
			
				
					|  |  |     data.reserve(klotski::ALL_CASES_SIZE_SUM); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     for (uint64_t head = 0; head < 16; ++head) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         for (const auto &range : AllCases::fetch()[head]) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             data.emplace_back(CommonCode::unsafe_create(head << 32 | range)); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     /// start benchmark
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     auto start = clock(); |  |  |     auto start = clock(); | 
			
		
	
		
		
			
				
					
					|  |  |     for (const auto &common_code : data) { |  |  |     for (const auto &common_code : all_common_codes) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         common_code.to_string(); |  |  |         common_code.to_string(); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |     return time_format(start, format) / (double)data.size(); |  |  |     return time_format(start, format) / (double)all_common_codes.size(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | double Benchmark::common_code_from_string(TIME format) noexcept { |  |  | double Benchmark::common_code_from_string(TIME format) noexcept { | 
			
		
	
		
		
			
				
					
					|  |  |     /// data preparation
 |  |  |     if (!data_ready) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |     std::vector<std::string> data; |  |  |         return -1; // data no ready -> skip
 | 
			
				
				
			
		
	
		
		
			
				
					|  |  |     data.reserve(klotski::ALL_CASES_SIZE_SUM); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     for (uint64_t head = 0; head < 16; ++head) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         for (const auto &range : AllCases::fetch()[head]) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             data.emplace_back( |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 CommonCode::unsafe_create(head << 32 | range).to_string() |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             ); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     /// start benchmark
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     auto start = clock(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     for (auto &&common_code : data) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         CommonCode{std::forward<std::string>(common_code)}; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     return time_format(start, format) / (double)data.size(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  | } |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  | double Benchmark::common_code_to_string_shorten(TIME format) noexcept { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     /// data preparation
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     std::vector<CommonCode> data; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     data.reserve(klotski::ALL_CASES_SIZE_SUM); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     for (uint64_t head = 0; head < 16; ++head) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         for (const auto &range : AllCases::fetch()[head]) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             data.emplace_back(CommonCode::unsafe_create(head << 32 | range)); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     /// start benchmark
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     auto start = clock(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     for (const auto &common_code : data) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         common_code.to_string(true); |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |     return time_format(start, format) / (double)data.size(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  | } |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  | double Benchmark::common_code_from_string_shorten(TIME format) noexcept { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     /// data preparation
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     std::vector<std::string> data; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     data.reserve(klotski::ALL_CASES_SIZE_SUM); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     for (uint64_t head = 0; head < 16; ++head) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         for (const auto &range : AllCases::fetch()[head]) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             data.emplace_back( |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 CommonCode::unsafe_create(head << 32 | range).to_string(true) |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             ); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     /// start benchmark
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     auto start = clock(); |  |  |     auto start = clock(); | 
			
		
	
		
		
			
				
					
					|  |  |     for (auto &&common_code : data) { |  |  |     for (auto &&common_code : all_common_codes_str) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         CommonCode{std::forward<std::string>(common_code)}; |  |  |         CommonCode{std::forward<std::string>(common_code)}; | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |     return time_format(start, format) / (double)data.size(); |  |  |     return time_format(start, format) / (double)all_common_codes_str.size(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
	
		
		
			
				
					|  | 
 |