#define _GNU_SOURCE
#include <sys/time.h>
#include <stdio.h>      /* standard I/O                */
#include <string.h>     /* for strcpy - 3 occurrences  */
#include <stdlib.h>     /* for exit   - 1 occurrence   */

struct timeval starttime,endtime;
double lscompile,comp1,te0;
int i;

int Compile1()
{
	gettimeofday(&starttime, NULL);
	for(i=0; i<20; i++) {
	system("compiledir/compile.sh");
	}
        gettimeofday(&endtime, NULL);
        te0=((double)(endtime.tv_sec*1000000-starttime.tv_sec*1000000+endtime.tv_usec-starttime.tv_usec))/1000000;
        comp1 = 20 / te0;
	printf("\n\tTest 1:\t20 Compiles of lsbench: %lf/s\n", comp1);
	system("compiledir/compilecleanup.sh");
return comp1;
}

int main() {

printf("\nRunning Compiler tests:\n");
FILE *fp;
Compile1();
lscompile = comp1 * 9.5;
fp=fopen("compiledir/lscompile.log", "w");
fprintf(fp, "%f\n", lscompile);
fclose(fp);
//printf("\n\tCompiling Index: %lf/s\n", lscompile);
printf("DONE.\n");
return(1);
}
