From 71422c2b488c8084770d52413c30b436d08dcc91 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 27 Jan 2018 15:06:55 -0500 Subject: [PATCH] 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 --- tests/A64/fuzz_with_unicorn.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/A64/fuzz_with_unicorn.cpp b/tests/A64/fuzz_with_unicorn.cpp index 60443899..3b122070 100644 --- a/tests/A64/fuzz_with_unicorn.cpp +++ b/tests/A64/fuzz_with_unicorn.cpp @@ -96,13 +96,14 @@ static void RunTestInstance(const std::array& regs, const std::array regs; + std::array vecs; + std::vector instructions(1); + for (size_t iteration = 0; iteration < 100000; ++iteration) { - std::array regs; std::generate(regs.begin(), regs.end(), []{ return RandInt(0, ~u64(0)); }); - std::array vecs; std::generate(vecs.begin(), vecs.end(), RandomVector); - std::vector instructions; - instructions.push_back(GenRandomInst(0, true)); + instructions[0] = GenRandomInst(0, true); u32 pstate = RandInt(0, 0xF) << 28; INFO("Instruction: 0x" << std::hex << instructions[0]);