rename product_is_valid to product_is_valid_slow
This commit is contained in:
+3
-2
@@ -1215,7 +1215,7 @@ static pair<size_t, size_t> compute_offset1_and_limit1(
|
||||
}
|
||||
}
|
||||
|
||||
bool product_is_valid(const string& s, uint8_t domain, uint8_t subdomain) {
|
||||
bool product_is_valid_slow(const string& s, uint8_t domain, uint8_t subdomain) {
|
||||
uint64_t product = decode_product_str(s);
|
||||
if (product == INVALID_PRODUCT) {
|
||||
return false;
|
||||
@@ -1370,7 +1370,7 @@ void product_speed_test(uint64_t seed) {
|
||||
time_fast += now() - start;
|
||||
|
||||
start = now();
|
||||
bool is_valid_slow = product_is_valid(s, 1, 0xFF);
|
||||
bool is_valid_slow = product_is_valid_slow(s, 1, 0xFF);
|
||||
time_slow += now() - start;
|
||||
|
||||
if (((z & 0xF) == 0) || is_valid_slow || is_valid_fast) {
|
||||
@@ -1383,5 +1383,6 @@ void product_speed_test(uint64_t seed) {
|
||||
|
||||
fprintf(stderr, "Total time (slow): %" PRId64 " usecs (%" PRIu64 " per product)\n", time_slow, time_slow / count);
|
||||
fprintf(stderr, "Total time (fast): %" PRId64 " usecs (%" PRIu64 " per product)\n", time_fast, time_fast / count);
|
||||
fprintf(stderr, "Fast vs. slow speedup: %zux\n", static_cast<size_t>(time_slow / time_fast));
|
||||
fprintf(stderr, "Disagreements: %zu\n", num_disagreements);
|
||||
}
|
||||
|
||||
+5
-3
@@ -5,14 +5,16 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
bool product_is_valid(
|
||||
// product_is_valid_slow is Sega's implementation; product_is_valid_fast
|
||||
// produces identical results but is about 7000 times faster.
|
||||
bool product_is_valid_slow(
|
||||
const std::string& s, uint8_t domain, uint8_t subdomain = 0xFF);
|
||||
bool product_is_valid_fast(
|
||||
const std::string& s, uint8_t domain, uint8_t subdomain = 0xFF);
|
||||
bool product_is_valid_fast(
|
||||
uint32_t product, uint8_t domain, uint8_t subdomain);
|
||||
uint32_t product, uint8_t domain, uint8_t subdomain = 0xFF);
|
||||
bool decoded_product_is_valid_fast(
|
||||
uint32_t product, uint8_t domain, uint8_t subdomain);
|
||||
uint32_t product, uint8_t domain, uint8_t subdomain = 0xFF);
|
||||
|
||||
std::string generate_product(uint8_t domain, uint8_t subdomain = 0xFF);
|
||||
std::unordered_map<uint32_t, std::string> generate_all_products(uint8_t domain = 0xFF, uint8_t subdomain = 0xFF);
|
||||
|
||||
Reference in New Issue
Block a user