This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
#include <dlfcn.h>
#include <stdio.h>
#include <sys/time.h>
static struct timeval startTime;
static char bGlobalTimer = 0;
static unsigned long getGlobalTimer()
{
struct timeval currentTime;
unsigned long nSeconds;
if ( bGlobalTimer == 0 )
{
gettimeofday( &startTime, NULL );
bGlobalTimer=1;
}
gettimeofday( ¤tTime, NULL );
nSeconds = (unsigned long)( currentTime.tv_sec - startTime.tv_sec );
return ( nSeconds * 1000 ) + (long) (( currentTime.tv_usec - startTime.tv_usec) / 1000 );
}
static char loadlib( const char *name, unsigned long *duration )
{
char ret = 0;
unsigned long start = getGlobalTimer();
/* loading with RTLD_NOW increases the loadtime by 30% */
/* if(dlopen( name , RTLD_NOW) ) */
if(dlopen( name , RTLD_LAZY) )
ret = 1;
*duration = getGlobalTimer() - start;
return ret;
}
int main(int argc, char * argv[] )
{
int i = 1;
char bVerbose = 0;
unsigned long start;
if( argc <= 1 || strcmp( argv[1] , "--help" ) == 0)
{
printf( "usage: shlload [-v] libname1 libname2 ....\n\n"
" loads the given shared libraries and \n"
" measures time needed for loading.\n\n"
"Options:\n"
" -v measures time for every given shared library\n" );
return 1;
}
if( 0 == strcmp( argv[1], "-v" ) )
{
bVerbose = 1;
i++;
}
start = getGlobalTimer();
while( i < argc )
{
unsigned long duration = 0;
if( bVerbose )
{
fprintf( stderr, "loading %s" , argv[i] );
fflush( stderr );
}
if( loadlib( argv[i], &duration ) )
{
if( bVerbose )
fprintf( stderr, " succeeded [%dms]\n", duration );
}
else
{
if( bVerbose )
fprintf( stderr, " failed\n" );
else
fprintf( stderr, "loading %s failed\n" , argv[i] );
}
i++;
}
fprintf( stderr, "Duration %d\n" , getGlobalTimer() - start );
}
Attachment:
lst
Description: application/java-vm
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |