#include #include #include #include #include #include #include int main(int argc, char** argv) { MYSQL* server; char *host = NULL, *str_baseline = NULL,*str_test = NULL, *errmsg = NULL; unsigned int port; int rval, iterations,i; clock_t begin,end; size_t offset; struct timeval real_begin,real_end,real_baseline,real_test; time_t time; double baseline, test, ratio, result; if(argc < 7){ fprintf(stderr,"Usage: %s \n",argv[0]); fprintf(stderr,"The ratio is measured as:\ntest time / baseline time\n"); fprintf(stderr,"The test fails if this ratio is exceeded.\n"); return 1; } ; if((str_baseline = calloc(256,sizeof(char))) == NULL){ return 1; } if((str_test = calloc(256,sizeof(char))) == NULL){ free(str_baseline); return 1; } iterations = atoi(argv[1]); host = strdup(argv[2]); port = atoi(argv[3]); ratio = atof(argv[6]); rval = 0; if(ratio <= 0.0){ return 1; } /**Testing direct connection to master*/ printf("Connecting to MySQL server through %s:%d.\n",host,port); gettimeofday(&real_begin,NULL); begin = clock(); if((server = mysql_init(NULL)) == NULL){ return 1; } if(mysql_real_connect(server,host,"maxuser","maxpwd",NULL,port,NULL,0) == NULL){ rval = 1; printf( "Failed to connect to database: Error: %s\n", mysql_error(server)); goto report; } for(i = 0;i