Skip to content

Commit

Permalink
Adjust the performance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanas committed Mar 8, 2024
1 parent 96b2a38 commit 1929382
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void bench1GB()
#define INPUT_SIZE 1000000000
static ALIGN(64) unsigned char input[INPUT_SIZE];
static ALIGN(64) unsigned char output[32];
KangarooTwelve(input, INPUT_SIZE, output, 32, 0, 0);
KT128(input, INPUT_SIZE, output, 32, 0, 0);
#undef INPUT_SIZE
}
#endif
Expand Down
18 changes: 10 additions & 8 deletions tests/testPerformance.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ cycles_t measurePerformance(int (*impl)(const unsigned char*, size_t,
void KangarooTwelve_SetProcessorCapabilities();
#endif

void printKangarooTwelvePerformanceHeader( void )
void printKangarooTwelvePerformanceHeader(int securityLevel)
{
#if defined(KeccakP1600_enable_simd_options) && !defined(KeccakP1600_disableParallelism)
KangarooTwelve_SetProcessorCapabilities();
#endif
printf("*** KangarooTwelve ***\n");
printf("*** KT%d ***\n", securityLevel);
printf("Using Keccak-p[1600,12] implementations:\n");
printf("- \303\2271: %s\n", KeccakP1600_GetImplementation());
#if defined(KeccakP1600_12rounds_FastLoop_supported)
Expand Down Expand Up @@ -100,7 +100,7 @@ void printKangarooTwelvePerformanceHeader( void )

void testPerformanceFull(int (*impl)(const unsigned char*, size_t,
unsigned char*, size_t,
const unsigned char*, size_t))
const unsigned char*, size_t), int extra)
{
const unsigned int chunkSize = 8192;
unsigned halfTones;
Expand All @@ -121,15 +121,15 @@ void testPerformanceFull(int (*impl)(const unsigned char*, size_t,
timePlus2Blocks = measurePerformance(impl, calibration, i+2*chunkSize);
timePlus4Blocks = measurePerformance(impl, calibration, i+4*chunkSize);
timePlus8Blocks = measurePerformance(impl, calibration, i+8*chunkSize);
timePlus168Blocks = measurePerformance(impl, calibration, i+168*chunkSize);
timePlus168Blocks = measurePerformance(impl, calibration, i+extra*chunkSize);
}
printf("%8u bytes: %9"PRId64" %s, %6.3f %s/byte\n", i, time, getTimerUnit(), time*1.0/i, getTimerUnit());
if (displaySlope) {
printf(" +1 block: %9"PRId64" %s, %6.3f %s/byte (slope)\n", timePlus1Block, getTimerUnit(), (timePlus1Block-(double)(time))*1.0/chunkSize/1.0, getTimerUnit());
printf(" +2 blocks: %9"PRId64" %s, %6.3f %s/byte (slope)\n", timePlus2Blocks, getTimerUnit(), (timePlus2Blocks-(double)(time))*1.0/chunkSize/2.0, getTimerUnit());
printf(" +4 blocks: %9"PRId64" %s, %6.3f %s/byte (slope)\n", timePlus4Blocks, getTimerUnit(), (timePlus4Blocks-(double)(time))*1.0/chunkSize/4.0, getTimerUnit());
printf(" +8 blocks: %9"PRId64" %s, %6.3f %s/byte (slope)\n", timePlus8Blocks, getTimerUnit(), (timePlus8Blocks-(double)(time))*1.0/chunkSize/8.0, getTimerUnit());
printf(" +168 blocks: %9"PRId64" %s, %6.3f %s/byte (slope)\n", timePlus168Blocks, getTimerUnit(), (timePlus168Blocks-(double)(time))*1.0/chunkSize/168.0, getTimerUnit());
printf(" +%d blocks: %9"PRId64" %s, %6.3f %s/byte (slope)\n", extra, timePlus168Blocks, getTimerUnit(), (timePlus168Blocks-(double)(time))*1.0/chunkSize/(extra*1.0), getTimerUnit());
displaySlope = 0;
}
}
Expand All @@ -145,8 +145,10 @@ void testPerformanceFull(int (*impl)(const unsigned char*, size_t,

void testKangarooTwelvePerformance()
{
printKangarooTwelvePerformanceHeader();
testPerformanceFull(KangarooTwelve);
printKangarooTwelvePerformanceHeader(128);
testPerformanceFull(KT128, 168);
printKangarooTwelvePerformanceHeader(256);
testPerformanceFull(KT256, 136);
}
void testPerformance()
{
Expand Down Expand Up @@ -195,6 +197,6 @@ void testPerformance()

if (comparison != NULL) {
printf("\n*** Non-K12 function for comparison: ***\n");
testPerformanceFull(comparison);
testPerformanceFull(comparison, 128);
}
}

0 comments on commit 1929382

Please sign in to comment.