mirror of https://github.com/x64dbg/zydis
Added number of decoded instructions to the performance-test tool output
This commit is contained in:
parent
428da82416
commit
f8f928a4a8
|
@ -509,8 +509,6 @@ typedef uint64_t ZydisInstructionAttributes;
|
|||
|
||||
// TODO: Update values
|
||||
|
||||
// TODO: Add IsAtomic
|
||||
|
||||
/**
|
||||
* @brief The instruction has the ModRM byte.
|
||||
*/
|
||||
|
|
|
@ -3140,9 +3140,9 @@ static ZydisStatus ZydisCollectOptionalPrefixes(ZydisDecoderContext* context,
|
|||
* @brief Decodes optional instruction parts like the ModRM byte, the SIB byte and additional
|
||||
* displacements and/or immediate values.
|
||||
*
|
||||
* @param context A pointer to the @c ZydisDecoderContext struct.
|
||||
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
||||
* @param optionalParts A pointer to the @c ZydisInstructionParts struct.
|
||||
* @param context A pointer to the @c ZydisDecoderContext struct.
|
||||
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
||||
* @param info A pointer to the @c ZydisInstructionParts struct.
|
||||
*
|
||||
* @return A zydis status code.
|
||||
*/
|
||||
|
|
|
@ -79,7 +79,7 @@ double GetCounter()
|
|||
/* Internal functions */
|
||||
/* ============================================================================================== */
|
||||
|
||||
void processBuffer(const char* buffer, size_t length, ZydisDecodeGranularity granularity,
|
||||
uint64_t processBuffer(const char* buffer, size_t length, ZydisDecodeGranularity granularity,
|
||||
ZydisBool format)
|
||||
{
|
||||
ZydisDecoder decoder;
|
||||
|
@ -103,6 +103,7 @@ void processBuffer(const char* buffer, size_t length, ZydisDecodeGranularity gra
|
|||
}
|
||||
}
|
||||
|
||||
uint64_t count = 0;
|
||||
size_t offset = 0;
|
||||
ZydisStatus status;
|
||||
ZydisDecodedInstruction instruction;
|
||||
|
@ -116,24 +117,29 @@ void processBuffer(const char* buffer, size_t length, ZydisDecodeGranularity gra
|
|||
puts("Unexpected decoding error");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
++count;
|
||||
if (format)
|
||||
{
|
||||
ZydisFormatterFormatInstruction(
|
||||
&formatter, &instruction, formatBuffer, sizeof(formatBuffer));
|
||||
}
|
||||
offset += instruction.length;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
void testPerformance(const char* buffer, size_t length, ZydisDecodeGranularity granularity,
|
||||
ZydisBool format)
|
||||
{
|
||||
uint64_t count = 0;
|
||||
StartCounter();
|
||||
for (uint8_t j = 0; j < 100; ++j)
|
||||
{
|
||||
processBuffer(buffer, length, granularity, format);
|
||||
count += processBuffer(buffer, length, granularity, format);
|
||||
}
|
||||
printf("Granularity %d, Formatting %d: %8.2f msec\n", granularity, format, GetCounter());
|
||||
printf("Granularity %d, Formatting %d, Instructions: ~%6.2fM, Time: %8.2f msec\n",
|
||||
granularity, format, (double)count / 1000000, GetCounter());
|
||||
}
|
||||
|
||||
void generateTestData(FILE* file, uint8_t encoding)
|
||||
|
|
Loading…
Reference in New Issue