#include #include #include #include #include int main(int argc, char *argv[]) { time_t start; int count, i; if (argc != 2) { fprintf (stderr, "usage: %s COUNT\n", argv[0]); exit (EXIT_FAILURE); } count = atoi (argv[1]); start = time (NULL); for (i = 1; i <= count; i++) { char path[32]; void *handle; sprintf (path, "./lib%04d.so", i); handle = dlopen (path, RTLD_LAZY); if (handle == NULL) { fprintf (stderr, "%s: dlopen failed\n", path); exit (EXIT_FAILURE); } } printf ("%d libraries loaded in %d seconds.\n", count, time (NULL) - start); }