#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <sys/time.h>

/* the time to run each test */
#define TIME_TO_WAIT 10

/* FOR EACH TEST DEFINE : */
/* define a ul in your test that says how many things it did */
extern unsigned long things_done;
/* define a string in your test to say what it wasd doing */
extern char * things;
/* a function (that doesn't return) to run your test */
void do_test(void);

struct timeval start,end;

/* on alarm print out results */
void on_alarm(int signo) 
{
  struct timeval diff ;
  double diff_secs;

  /* grab things done before we continue as we do not kill 
     the potentially running threads until we exit below */
  unsigned long stamp = things_done;
  
  gettimeofday(&end, NULL);
  timersub( &end, &start , &diff );
  diff_secs = diff.tv_sec + diff.tv_usec*1e-6;

  printf("%d ", stamp);
  printf("%.0f\n", stamp / diff_secs );

  exit(0);
}


/* main */
int main(int argc, char *argv[]) 
{
	/* setup alarm handler */
	static struct sigaction alarm_m;
	alarm_m.sa_handler = on_alarm;
	sigfillset(&(alarm_m.sa_mask));
	sigaction(SIGALRM , &alarm_m, NULL);

	alarm( TIME_TO_WAIT );

	gettimeofday( &start , NULL );

	do_test();
	
	printf("Please make do_test() not return\n");
	exit(1);
}

