Mercurial > flash_v2
changeset 1337:1ded88da2dd4
Add example use of profiling to 'ping_test'
| author | gthomas |
|---|---|
| date | Thu, 30 Oct 2003 14:12:45 +0000 |
| parents | 4abdcd2f65a9 |
| children | 2a68919a1b99 |
| files | packages/net/common/current/ChangeLog packages/net/common/current/tests/ping_test.c |
| diffstat | 2 files changed, 32 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/net/common/current/ChangeLog +++ b/packages/net/common/current/ChangeLog @@ -1,3 +1,7 @@ +2003-10-30 Gary Thomas <gary@mlbassoc.com> + + * tests/ping_test.c: Enable profiling if configured in - example use only. + 2003-10-16 Jay Foster <jay@systech.com> Andrew Lunn <andrew.lunn@ascom.ch>
--- a/packages/net/common/current/tests/ping_test.c +++ b/packages/net/common/current/tests/ping_test.c @@ -364,6 +364,31 @@ ping6_test( struct sockaddr_in6 *host) } #endif +#ifdef CYGPKG_PROFILE_GPROF +#include <cyg/profile/profile.h> + +extern char _stext, _etext; // Defined by the linker + +static void +start_profile(void) +{ + // This starts up the system-wide profiling, gathering + // profile information on all of the code, with a 16 byte + // "bucket" size, at a rate of 100us/profile hit. + // Note: a bucket size of 16 will give pretty good function + // resolution. Much smaller and the buffer becomes + // much too large for very little gain. + // Note: a timer period of 100us is also a reasonable + // compromise. Any smaller and the overhead of + // handling the timter (profile) interrupt could + // swamp the system. A fast processor might get + // by with a smaller value, but a slow one could + // even be swamped by this value. If the value is + // too large, the usefulness of the profile is reduced. + profile_on(&_stext, &_etext, 16, 100); +} +#endif + static void ping_test(struct bootp *bp) { @@ -405,6 +430,9 @@ net_test(cyg_addrword_t p) diag_printf("Start PING test\n"); TNR_INIT(); init_all_network_interfaces(); +#ifdef CYGPKG_PROFILE_GPROF + start_profile(); +#endif #ifdef CYGHWR_NET_DRIVER_ETH0 if (eth0_up) { ping_test(ð0_bootp_data);
