Added number of decoded instructions to the performance-test tool output

This commit is contained in:
flobernd 2017-07-05 16:28:16 +02:00
parent 428da82416
commit f8f928a4a8
3 changed files with 13 additions and 9 deletions

View File

@ -509,8 +509,6 @@ typedef uint64_t ZydisInstructionAttributes;
// TODO: Update values
// TODO: Add IsAtomic
/**
* @brief The instruction has the ModRM byte.
*/

View File

@ -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.
*/

View File

@ -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)