ulonglong my_getsystime() { #ifdef HAVE_CLOCK_GETTIME struct timespec tp; clock_gettime(CLOCK_REALTIME, &tp); return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100; #elif defined(__WIN__) LARGE_INTEGER t_cnt; if (query_performance_frequency) { QueryPerformanceCounter(&t_cnt); return ((t_cnt.QuadPart / query_performance_frequency * 10000000) + ((t_cnt.QuadPart % query_performance_frequency) * 10000000 / query_performance_frequency) + query_performance_offset); } return 0; #elif defined(__NETWARE__) NXTime_t tm; NXGetTime(NX_SINCE_1970, NX_NSECONDS, &tm); return (ulonglong)tm/100; #else /* TODO: check for other possibilities for hi-res timestamping */ struct timeval tv; gettimeofday(&tv,NULL); return (ulonglong)tv.tv_sec*10000000+(ulonglong)tv.tv_usec*10; #endif }
void Performance::Get_Perf_Data(DWORD perf_data_type, int snapshot) { NXTime_t NXTime; // Get the performance data stored by the system. #ifdef _DEBUG cout << " Getting system performance data." << endl << flush; #endif NXGetTime(NX_SINCE_BOOT, NX_MSECONDS, &NXTime); //NX_TICKS time_counter[snapshot] = (__int64)NXTime; if (snapshot == LAST_SNAPSHOT) { // calculate time diff in clock ticks.. timediff = (time_counter[LAST_SNAPSHOT] - time_counter[FIRST_SNAPSHOT]); } switch (perf_data_type) { case PERF_PROCESSOR: Get_CPU_Counters(snapshot); break; case PERF_NETWORK_TCP: Get_TCP_Counters(snapshot); break; case PERF_NETWORK_INTERFACE: Get_NI_Counters(snapshot); break; default: break; } }
/****************************************************************************** run_test() Run the given test case. ******************************************************************************/ void run_test(char *test) { char temp[PATH_MAX]; char *rstr; double elapsed = 0; int skip = FALSE, ignore=FALSE; int restart = FALSE; int flag = FALSE; struct stat info; // skip tests in the skip list snprintf(temp, PATH_MAX, " %s ", test); skip = (strindex(skip_test, temp) != NULL); if (skip == FALSE) ignore = (strindex(ignore_test, temp) != NULL); if (ignore) { // show test log_msg("%-46s ", test); // ignore rstr = TEST_IGNORE; ++total_ignore; } else if (!skip) // skip test? { char test_file[PATH_MAX]; char master_opt_file[PATH_MAX]; char slave_opt_file[PATH_MAX]; char slave_master_info_file[PATH_MAX]; char result_file[PATH_MAX]; char reject_file[PATH_MAX]; char out_file[PATH_MAX]; char err_file[PATH_MAX]; int err; arg_list_t al; NXTime_t start, stop; // skip slave? flag = skip_slave; skip_slave = (strncmp(test, "rpl", 3) != 0); if (flag != skip_slave) restart = TRUE; // create files snprintf(master_opt_file, PATH_MAX, "%s/%s-master.opt", test_dir, test); snprintf(slave_opt_file, PATH_MAX, "%s/%s-slave.opt", test_dir, test); snprintf(slave_master_info_file, PATH_MAX, "%s/%s.slave-mi", test_dir, test); snprintf(reject_file, PATH_MAX, "%s/%s%s", result_dir, test, REJECT_SUFFIX); snprintf(out_file, PATH_MAX, "%s/%s%s", result_dir, test, OUT_SUFFIX); snprintf(err_file, PATH_MAX, "%s/%s%s", result_dir, test, ERR_SUFFIX); // netware specific files snprintf(test_file, PATH_MAX, "%s/%s%s", test_dir, test, NW_TEST_SUFFIX); if (stat(test_file, &info)) { snprintf(test_file, PATH_MAX, "%s/%s%s", test_dir, test, TEST_SUFFIX); if (access(test_file,0)) { printf("Invalid test name %s, %s file not found\n",test,test_file); return; } } snprintf(result_file, PATH_MAX, "%s/%s%s", result_dir, test, NW_RESULT_SUFFIX); if (stat(result_file, &info)) { snprintf(result_file, PATH_MAX, "%s/%s%s", result_dir, test, RESULT_SUFFIX); } // init scripts snprintf(master_init_script, PATH_MAX, "%s/%s-master.sh", test_dir, test); if (stat(master_init_script, &info)) master_init_script[0] = NULL; else restart = TRUE; snprintf(slave_init_script, PATH_MAX, "%s/%s-slave.sh", test_dir, test); if (stat(slave_init_script, &info)) slave_init_script[0] = NULL; else restart = TRUE; // read options if (read_option(master_opt_file, master_opt)) restart = TRUE; if (read_option(slave_opt_file, slave_opt)) restart = TRUE; if (read_option(slave_master_info_file, slave_master_info)) restart = TRUE; // cleanup previous run remove(reject_file); remove(out_file); remove(err_file); // start or restart? if (!master_running) mysql_start(); else if (restart) mysql_restart(); // let the system stabalize sleep(1); // show test log_msg("%-46s ", test); // args init_args(&al); add_arg(&al, "%s", mysqltest_file); add_arg(&al, "--no-defaults"); add_arg(&al, "--port=%u", master_port); add_arg(&al, "--database=%s", db); add_arg(&al, "--user=%s", user); add_arg(&al, "--password=%s", password); add_arg(&al, "--silent"); add_arg(&al, "--basedir=%s/", mysql_test_dir); add_arg(&al, "--host=127.0.0.1"); add_arg(&al, "-v"); add_arg(&al, "-R"); add_arg(&al, "%s", result_file); if (use_openssl) { add_arg(&al, "--ssl-ca=%s", ca_cert); add_arg(&al, "--ssl-cert=%s", client_cert); add_arg(&al, "--ssl-key=%s", client_key); } // start timer NXGetTime(NX_SINCE_BOOT, NX_USECONDS, &start); // spawn err = spawn(mysqltest_file, &al, TRUE, test_file, out_file, err_file); // stop timer NXGetTime(NX_SINCE_BOOT, NX_USECONDS, &stop); // calculate elapsed = ((double)(stop - start)) / NX_USECONDS; total_time += elapsed; // free args free_args(&al); if (err == 0) { // pass rstr = TEST_PASS; ++total_pass; // increment total ++total_test; } else if (err == 62) { // skip rstr = TEST_SKIP; ++total_skip; } else if (err == 1) { // fail rstr = TEST_FAIL; ++total_fail; // increment total ++total_test; } else { rstr = TEST_BAD; } } else // early skips { // show test log_msg("%-46s ", test); // skip rstr = TEST_SKIP; ++total_skip; } // result log_msg("%10.06f %-14s\n", elapsed, rstr); }