diff options
author | Michael Brown | 2014-04-23 18:43:18 +0200 |
---|---|---|
committer | Michael Brown | 2014-04-28 00:14:43 +0200 |
commit | e5f6a9be384f6adc2b50ffdb8781e81327b790aa (patch) | |
tree | 42efc59b490b68891abd81a5cc11ac938c3848c2 /src/tests/tcpip_test.c | |
parent | [libc] Add flsll() (diff) | |
download | ipxe-e5f6a9be384f6adc2b50ffdb8781e81327b790aa.tar.gz ipxe-e5f6a9be384f6adc2b50ffdb8781e81327b790aa.tar.xz ipxe-e5f6a9be384f6adc2b50ffdb8781e81327b790aa.zip |
[profile] Add generic profiling infrastructure
Signed-off-by: Michael Brown <mcb30@ipxe.org>
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 4ff23e3f..00c88ae3 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__ ) |