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: Update values
|
||||||
|
|
||||||
// TODO: Add IsAtomic
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The instruction has the ModRM byte.
|
* @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
|
* @brief Decodes optional instruction parts like the ModRM byte, the SIB byte and additional
|
||||||
* displacements and/or immediate values.
|
* displacements and/or immediate values.
|
||||||
*
|
*
|
||||||
* @param context A pointer to the @c ZydisDecoderContext struct.
|
* @param context A pointer to the @c ZydisDecoderContext struct.
|
||||||
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
||||||
* @param optionalParts A pointer to the @c ZydisInstructionParts struct.
|
* @param info A pointer to the @c ZydisInstructionParts struct.
|
||||||
*
|
*
|
||||||
* @return A zydis status code.
|
* @return A zydis status code.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -79,7 +79,7 @@ double GetCounter()
|
||||||
/* Internal functions */
|
/* 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)
|
ZydisBool format)
|
||||||
{
|
{
|
||||||
ZydisDecoder decoder;
|
ZydisDecoder decoder;
|
||||||
|
@ -103,6 +103,7 @@ void processBuffer(const char* buffer, size_t length, ZydisDecodeGranularity gra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t count = 0;
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
ZydisStatus status;
|
ZydisStatus status;
|
||||||
ZydisDecodedInstruction instruction;
|
ZydisDecodedInstruction instruction;
|
||||||
|
@ -116,6 +117,7 @@ void processBuffer(const char* buffer, size_t length, ZydisDecodeGranularity gra
|
||||||
puts("Unexpected decoding error");
|
puts("Unexpected decoding error");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
++count;
|
||||||
if (format)
|
if (format)
|
||||||
{
|
{
|
||||||
ZydisFormatterFormatInstruction(
|
ZydisFormatterFormatInstruction(
|
||||||
|
@ -123,17 +125,21 @@ void processBuffer(const char* buffer, size_t length, ZydisDecodeGranularity gra
|
||||||
}
|
}
|
||||||
offset += instruction.length;
|
offset += instruction.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testPerformance(const char* buffer, size_t length, ZydisDecodeGranularity granularity,
|
void testPerformance(const char* buffer, size_t length, ZydisDecodeGranularity granularity,
|
||||||
ZydisBool format)
|
ZydisBool format)
|
||||||
{
|
{
|
||||||
|
uint64_t count = 0;
|
||||||
StartCounter();
|
StartCounter();
|
||||||
for (uint8_t j = 0; j < 100; ++j)
|
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)
|
void generateTestData(FILE* file, uint8_t encoding)
|
||||||
|
|
Loading…
Reference in New Issue