fuzz_with_unicorn: Move data outside loop

Given we know we're only ever going to use one instruction, we can just presize the vector and reassign to it
instead of potentially reallocating the same memory 100000 times
This commit is contained in:
Lioncash 2018-01-27 15:06:55 -05:00 committed by Merry
parent 763a4783f9
commit 7f31a9b5ab

View File

@ -96,13 +96,14 @@ static void RunTestInstance(const std::array<u64, 31>& regs, const std::array<Ve
}
TEST_CASE("A64: Single random instruction", "[a64]") {
std::array<u64, 31> regs;
std::array<Vector, 32> vecs;
std::vector<u32> instructions(1);
for (size_t iteration = 0; iteration < 100000; ++iteration) {
std::array<u64, 31> regs;
std::generate(regs.begin(), regs.end(), []{ return RandInt<u64>(0, ~u64(0)); });
std::array<Vector, 32> vecs;
std::generate(vecs.begin(), vecs.end(), RandomVector);
std::vector<u32> instructions;
instructions.push_back(GenRandomInst(0, true));
instructions[0] = GenRandomInst(0, true);
u32 pstate = RandInt<u32>(0, 0xF) << 28;
INFO("Instruction: 0x" << std::hex << instructions[0]);