#include <stdio.h> #include <pthread.h> #include "timer.h" double total; /*----------------------------------------------------------------------------- Function name: nada ------------------------------------------------------------------------------- Preconditions: -None Postconditions: -None Algorithm: -None to speak of Exception/Error Handlig: -None -----------------------------------------------------------------------------*/ void *nada ( void *args) { pthread_exit (NULL); } /*----------------------------------------------------------------------------- Function name: main ------------------------------------------------------------------------------- Preconditions: -None Postconditions: -100000 threads have been created Algorithm: -Set everything to default values -Time the creation of 100000 threads Exception/Error Handlig: -None -----------------------------------------------------------------------------*/ int main () { long long i; pthread_t thread; timer stopwatch; total = 0.0f; for (i=0; i<100000; i++) { stopwatch.start(); pthread_create (&thread, NULL, nada, NULL); stopwatch.stop(); total += stopwatch.read (); stopwatch.reset (); if (i%1000 == 0) { printf ("%i\n", i); } } printf ("%.3f\n", total/100000.0f); }