diff options
Diffstat (limited to 'src/tests/tcpip_test.c')
| -rw-r--r-- | src/tests/tcpip_test.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/tests/tcpip_test.c b/src/tests/tcpip_test.c index 4ff23e3f2..00c88ae32 100644 --- a/src/tests/tcpip_test.c +++ b/src/tests/tcpip_test.c @@ -36,6 +36,9 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <ipxe/profile.h> #include <ipxe/tcpip.h> +/** Number of sample iterations for profiling */ +#define PROFILE_COUNT 16 + /** A TCP/IP fixed-data test */ struct tcpip_test { /** Data */ @@ -173,10 +176,10 @@ static void tcpip_okx ( struct tcpip_test *test, const char *file, static void tcpip_random_okx ( struct tcpip_random_test *test, const char *file, unsigned int line ) { uint8_t *data = ( tcpip_data + test->offset ); + struct profiler profiler; uint16_t expected; uint16_t generic_sum; uint16_t sum; - unsigned long elapsed; unsigned int i; /* Sanity check */ @@ -194,12 +197,20 @@ static void tcpip_random_okx ( struct tcpip_random_test *test, okx ( generic_sum == expected, file, line ); /* Verify optimised tcpip_continue_chksum() result */ - simple_profile(); sum = tcpip_continue_chksum ( TCPIP_EMPTY_CSUM, data, test->len ); - elapsed = simple_profile(); okx ( sum == expected, file, line ); - DBG ( "TCPIP checksummed %zd bytes (+%zd) in %ld ticks\n", - test->len, test->offset, elapsed ); + + /* Profile optimised calculation */ + memset ( &profiler, 0, sizeof ( profiler ) ); + for ( i = 0 ; i < PROFILE_COUNT ; i++ ) { + profile_start ( &profiler ); + sum = tcpip_continue_chksum ( TCPIP_EMPTY_CSUM, data, + test->len ); + profile_stop ( &profiler ); + } + DBG ( "TCPIP checksummed %zd bytes (+%zd) in %ld +/- %ld ticks\n", + test->len, test->offset, profile_mean ( &profiler ), + profile_stddev ( &profiler ) ); } #define tcpip_random_ok( test ) tcpip_random_okx ( test, __FILE__, __LINE__ ) |
