Some performance updates for the M6502 test code.

This commit is contained in:
Adrian Conlon 2024-03-15 13:16:25 +00:00
parent 3ca8fc4d99
commit 81aecef48b
3 changed files with 16 additions and 8 deletions

View File

@ -130,17 +130,19 @@ bool checker_t::checkState(test_t test) {
auto& cpu = runner().CPU();
auto& ram = runner().RAM();
const auto expected_cycles = test.cycles();
const auto& expected_cycles = test.cycles();
const auto& actual_cycles = m_actualCycles;
m_cycle_count_mismatch = expected_cycles.size() != actual_cycles.size();
if (m_cycle_count_mismatch)
return false;
size_t actual_idx = 0;
for (const auto expected_cycle : expected_cycles) {
if (actual_idx >= actual_cycles.size()) {
m_cycle_count_mismatch = true;
return false; // more expected cycles than actual
}
auto expected_data = expected_cycle.begin();
const auto& actual = actual_cycles.at(actual_idx++); // actual could be less than expected
const auto& actual = actual_cycles[actual_idx++];
const auto expected_address = uint16_t(int64_t(*expected_data++));
const auto actual_address = std::get<0>(actual);
@ -154,6 +156,12 @@ bool checker_t::checkState(test_t test) {
const auto actual_action = std::get<2>(actual);
check("Cycle action", expected_action.value_unsafe(), actual_action);
}
if (actual_idx < actual_cycles.size()) {
m_cycle_count_mismatch = true;
return false; // less expected cycles than actual
}
if (!m_messages.empty())
return false;

View File

@ -44,7 +44,7 @@ private:
void raise(std::string_view what, std::string_view expected, std::string_view actual);
template<class T>
bool check(std::string_view what, T expected, T actual) {
constexpr bool check(std::string_view what, T expected, T actual) noexcept {
const auto success = actual == expected;
if (!success)
raise(what, expected, actual);

View File

@ -36,7 +36,7 @@ int main() {
opcode.load();
auto test_generator = opcode.generator();
std::vector<std::string> test_names;
std::vector<std::string_view> test_names;
while (test_generator) {
const auto test = test_generator();
@ -66,7 +66,7 @@ int main() {
break;
}
test_names.push_back(std::string(std::string_view(test.name())));
test_names.push_back(test.name().get_string().value());
}
}